namespace TuanHA_Combat_Routine
{
    using CommonBehaviors.Actions;
    using Styx;
    using Styx.Common;
    using Styx.CommonBot;
    using Styx.CommonBot.Inventory;
    using Styx.CommonBot.Routines;
    using Styx.Helpers;
    using Styx.Pathing;
    using Styx.TreeSharp;
    using Styx.WoWInternals;
    using Styx.WoWInternals.WoWObjects;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Security.Cryptography;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    using System.Windows.Media;

    public class Classname : CombatRoutine
    {
        private static int _bonusJudgementRange;
        private Composite _combatBehavior;
        private Composite _deathBehavior;
        private static string _hasTalent = "";
        private Composite _preCombatBuffBehavior;
        private Composite _restBehavior;
        private static readonly Dictionary<ulong, DateTime> AutoRezListCache = new Dictionary<ulong, DateTime>();
        private static readonly HashSet<int> BuffBurstHS = new HashSet<int> { 
            0x1a436, 0x3004, 0x1da7f, 0xc847, 0xbf78, 0x190a0, 0x1e82e, 0x1a1c8, 0x4c76, 0xbe5, 0x30b8, 0x7c8c, 0x19d51, 0x152aa, 0x1528d, 0xca01, 
            0xc9ea, 0x35b6, 0x1bd81, 0x1bd83, 0x1bcc2, 0x6b7, 0x1be1f
         };
        private static readonly HashSet<int> BuffEnrageHS = new HashSet<int> { 0x32f6, 0x4843, 0xd98e };
        private static readonly HashSet<int> BuffHealHS = new HashSet<int> { 
            0x306, 0x22e8, 0x83e3, 0xbd36, 0xef6f, 0x3ce, 0xca12, 0x8b, 0x12ead, 0x12eb1, 0xbd74, 0x1c1cf, 0x1e70a, 0x1c1e7, 0x1e4b1, 0x11, 
            0x81b6, 0x12b7d, 0x51bd
         };
        private static DateTime BurstLast;
        private static Color colorlog;
        private static readonly string CombatRoutineFolder = "TuanHAPaladinSpecialEdition";
        public static string CurrentSpec;
        private static bool CurrentTargetCheckDebuffCCBreakonDamage;
        private static double CurrentTargetCheckDist;
        private static bool CurrentTargetCheckFacing;
        private static bool CurrentTargetCheckInLineOfSpellSight;
        private static bool CurrentTargetCheckInvulnerable;
        private static bool CurrentTargetCheckInvulnerableMagic;
        private static bool CurrentTargetCheckInvulnerablePhysic;
        private static bool CurrentTargetCheckIsEnemy;
        private static WoWUnit CurrentTargetCheckLast;
        private static DateTime CurrentTargetCheckLastTime;
        private static TimeSpan CurrentTargetCheckTimeOut;
        private const string DB = "wc.db";
        private static readonly HashSet<int> DebuffCCBreakonDamageHS = new HashSet<int> { 
            0x82e, 0x19bcd, 0x63, 0x7bad, 0xd1b, 0x6f0, 0xa4d, 0x1c244, 0x1c186, 0x1ed93, 0x1edd7, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0x4e62, 0x1a72, 0x4c2f, 0x2053c, 0x18d6, 0x1966d, 0x4bba
         };
        private static readonly HashSet<int> DebuffCCDurationHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffCCHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffCCleanseASAPHSWarrior = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0xfa2c, 0x1fba, 0x1bc80 };
        private static readonly HashSet<int> DebuffCCleanseASAPPvEHS = new HashSet<int> { 
            0x1cf18, 0x1d4b1, 0x1cabc, 0x1e7bf, 0x1e083, 0x1e084, 0x21604, 0x2160f, 0x2158b, 0x21606, 0x21540, 0x21699, 0x213f9, 0x213fb, 0x213f7, 0x213f5, 
            0x21b38, 0x1ccbd, 0x23736
         };
        private static readonly HashSet<int> DebuffCCleanseASAPPvPHS = new HashSet<int> { 
            0x19bcd, 0x1e201, 0xae1c, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0xd1b, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 
            0x1c244, 0x1a85, 0x1bd21, 0x1ed93, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 0x4e62, 
            0x14303, 0x5e9, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 0x1d079, 0x2856, 0x259d3, 0x4bba, 0x1b934
         };
        private static readonly HashSet<int> DebuffDisarmHS = new HashSet<int> { 0xc56d, 0x2a4, 0x1cd4d, 0xca0a, 0x1ca78, 0x1edfa, 0xfa3a, 0x165fc };
        private static readonly HashSet<int> DebuffDoNotCleanseHS = new HashSet<int> { 0x213f8, 0x213fa, 0x213f4, 0x213f6, 0x759c, 0x21d71, 0x21dec, 0x21ded, 0x8862 };
        private static readonly HashSet<int> DebuffDoNotHealHS = new HashSet<int> { 0x2187d, 0x21874, 0x25d, 0x83fa, 0x1e177, 0x1e130, 0x1dc5d, 0x21890, 0x1de02, 0x22e11 };
        private static readonly HashSet<int> DebuffFearDurationHS = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0x156c, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 0x1c244, 0xfa2c, 0x1fba, 0x1bc80, 0x2053c, 0x18d6, 0x154a4, 0x1966d };
        private static readonly HashSet<int> DebuffMagicCCDurationHS = new HashSet<int> { 
            710, 0x12bec, 0x1cb16, 0x19bcd, 0x1c428, 0x1e201, 0x1cdff, 0xae1c, 0x63, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 
            0xd1b, 0x355, 0x1b06a, 0xa4d, 0xc93a, 0x15a31, 0x1d120, 0x156c, 0x1ed26, 0x1c244, 0x1a85, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 0x4e62, 0x14303, 0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 
            0xc557, 0x1d079, 0x2856, 0x259d3, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffRootCanCleanseHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x215ba, 
            0x1c1fd, 0x1669f, 0x1e20f, 0xd5b2, 0x1047
         };
        private static readonly HashSet<int> DebuffRootCanCloakHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x1e20f, 
            0xd5b2, 0x1bee4, 0x1047
         };
        private static readonly HashSet<int> DebuffRootHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047
         };
        private static readonly HashSet<int> DebuffRootorSnareHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047, 0xc501, 0x1aedc, 
            0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 0x1e34f, 0xe10, 
            0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 0x3023, 0x1c138, 
            0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5
         };
        private static readonly HashSet<int> DebuffSilenceHS = new HashSet<int> { 
            0x1fa3d, 0x61d6, 0x13a63, 0x703a, 0x10e3b, 0xc5b5, 0x7cbf, 0x1be3e, 0x18ea3, 0x532, 0x1c446, 0x3c7f, 0x4842, 0xd6ed, 0x86ba, 0x13d6d, 
            0x1ba87, 0x1c7e5, 0x5ec3, 0x20539, 0xb974, 0x798d
         };
        private static readonly HashSet<int> DebuffSnareHS = new HashSet<int> { 
            0xc501, 0x1aedc, 0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 
            0x1e34f, 0xe10, 0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 
            0x3023, 0x1c138, 0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5, 0x11fd2
         };
        private static readonly HashSet<int> DebuffStunDurationHS = new HashSet<int> { 
            0x15ea6, 0x1bc89, 0x1918b, 0x1cb16, 0x1edf3, 0x1dd82, 0x1d260, 0x729, 0xae1c, 0xd602, 0x19c79, 0x1caaa, 0x16698, 0x355, 0x1b06a, 0x5f4a, 
            0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0x1c139, 0x14303, 0x764b, 0x20448, 0x1d079, 0x5045, 0x1a6a2, 0x1bd21
         };
        private static readonly HashSet<int> DebuffStunFearDurationHS = new HashSet<int> { 
            0x1d260, 0x729, 0xae1c, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 0x355, 0x1b06a, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 
            0x5f4a, 0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1c139, 0x14303, 0x764b, 0x20448, 0x154a4, 
            0x19d2b, 0x1a6a2
         };
        private static readonly HashSet<int> DoNotInterrupt = new HashSet<int> { 0xe40, 0x12fc7, 0xdd41, 0x193, 0x1bbf8, 0x5045, 0x1c25e, 0x1aacb };
        private static DateTime DoNotMove;
        private static WoWUnit EnemyLightsHammer;
        private static readonly Dictionary<ulong, DateTime> EnemyListCache = new Dictionary<ulong, DateTime>();
        private static DateTime EnemyListCacheClearLast;
        internal static int FailLoginAttempt;
        internal static DateTime FailLoginNextTime;
        private static readonly List<WoWUnit> FarFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarFriendlyUnits = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarUnFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarUnFriendlyUnits = new List<WoWUnit>();
        private static DateTime FlashofLightDPSSpec;
        private static readonly Dictionary<ulong, DateTime> FriendListCache = new Dictionary<ulong, DateTime>();
        private static DateTime FriendListCacheClearLast;
        private static DateTime GlobalCheckTime;
        private static readonly List<WoWPlayer> GroupHealingMembers = new List<WoWPlayer>();
        private static bool GroupHealingOn;
        private static string HasGlyph;
        private static string HasGlyphName;
        private static double HealWeightUnitHeal;
        private static readonly HashSet<WoWApplyAuraType> HS_HasAuraTypeDOT = new HashSet<WoWApplyAuraType> { 3, 0x59 };
        private static readonly HashSet<int> HS_NOTDOT = new HashSet<int> { 
            0x14b0b, 0x14b0a, 0x14b09, 0x173f7, 0x116a0, 0xb07d, 0x1d33b, 0x1ce0b, 0xd193, 0xe24e, 0x187f4, 0xe17b, 0xe17c, 0x139e2, 0x64ab, 0x177df, 
            0x17641, 0x2bbc, 0x1f3e5
         };
        private const string initVector = "www.tuanha.biz/l";
        private static readonly Dictionary<ulong, DateTime> InLineOfSpellSightCache = new Dictionary<ulong, DateTime>();
        private static readonly HashSet<int> InvulnerableHS = new HashSet<int> { 0x83fa, 0x4b3f, 0xb9e1, 0x282, 0xb17e, 0x6cb3 };
        private static readonly HashSet<int> InvulnerableRootandSnareHS = new HashSet<int> { 0xd017, 0xb74c, 0x414 };
        private static readonly HashSet<int> InvulnerableSpellHS = new HashSet<int> { 0xbe43, 0x79f8, 0x1c40b, 0x1ff2, 0x1bd6c, 0x5d70, 0x201c3 };
        private static readonly HashSet<int> InvulnerableStunHS = new HashSet<int> { 0xbe98, 0xb74c };
        private static bool IsOverrideModeOn;
        private static bool IsUsingAFKBot;
        private static TimeSpan ItemCooldownBack;
        private static readonly Dictionary<WoWItem, DateTime> ItemsCooldownCache = new Dictionary<WoWItem, DateTime>();
        private const int keysize = 0x100;
        public Keys KeyTwo;
        private static DateTime LastAutoTarget;
        private static DateTime LastBurstCalled;
        private static string LastCastSpell;
        private static DateTime LastCastTime;
        private static WoWUnit LastCastUnit;
        private static DateTime LastClickRemoteLocation;
        private static DateTime LastHand;
        private static DateTime LastInterrupt;
        private static DateTime LastRotationTime;
        private static DateTime LastSwitch;
        private static DateTime LastWriteDebug;
        private static DateTime LastWriteLog;
        private static readonly string LocalFolder = Path.Combine(Utilities.AssemblyDirectory, @"Routines\" + CombatRoutineFolder);
        internal static bool LoginCheckVal = false;
        private static ulong MeGuid;
        private static double MeMaxHealth;
        internal const string Msp = "p";
        internal static readonly HashSet<int> MyHandHS = new HashSet<int> { 0x1bd77, 0x414, 0x3fe, 0x25a8, 0x40e };
        private static WoWUnit MyLastTarget;
        private static double MyLatency;
        private static readonly List<WoWUnit> NearbyFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyFriendlyUnits = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyUnFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyUnFriendlyUnits = new List<WoWUnit>();
        private static readonly HashSet<uint> NeedHealUnitHS = new HashSet<uint> { 0xf3ea, 0x116ec, 0x115fe, 0x115fd, 0x116bd, 0x11a1a, 0x11a1b, 0x11a1d, 0x11a1c, 0x11894, 0x117b4, 0x117b4, 0x1193b, 0x1193c, 0x11738 };
        private static DateTime NextSuppressMessage = DateTime.MinValue;
        private static readonly HashSet<string> OverrideToSpellHS = new HashSet<string> { "Eternal Flame", "Turn Evil", "Exorcism", "Fist of Justice" };
        private const string PATTERN = "/!svn/ver/(?'version'[0-9]*)/";
        private static WoWUnit PlayerFriendlyCleanse;
        private static WoWUnit PlayerFriendlyCleanseASAP;
        private static WoWUnit PlayerFriendlyHandofSacASAP;
        private static WoWUnit PlayerHandofProtectionFriendRemoveCC;
        private static WoWUnit PlayerHandofPurityDebuff;
        private static WoWUnit PlayerHolyRadiance;
        private static WoWUnit PlayerLightsHammer;
        private static string ProtPreferedSeal;
        private static readonly List<WoWPlayer> RaidPartyMembers = new List<WoWPlayer>();
        internal static string RealName;
        private const int RezMaxMobsNear = 0;
        private const int RezWaitDist = 20;
        private const int RezWaitTime = 10;
        internal static string SafeCharName;
        private static readonly HashSet<int> SafeUsingCooldownHS = new HashSet<int> { 0x149d, 0xb74c };
        private static DateTime SealSwitchLast;
        private static DateTime SetAutoAttackLast;
        private static double spellCooldownBack;
        private static readonly Dictionary<string, DateTime> SpellsCooldownCache = new Dictionary<string, DateTime>();
        private static readonly HashSet<string> SpellsCooldownHS = new HashSet<string> { 
            "Arcane Torrent", "Berserking", "Blood Fury", "Cannibalize", "Darkflight", "Escape Artist", "Every Man for Himself", "Gift of the Naaru", "Rocket Jump", "Shadowmeld", "Stoneform", "War Stomp", "Will of the Forsaken", "Avenging Wrath", "Ardent Defender", "Blinding Light", 
            "Beacon of Light", "Consecration", "Crusader Strike", "Devotion Aura", "Divine Favor ", "Divine Plea", "Divine Protection", "Divine Shield", "Execution Sentence", "Fist of Justice", "Guardian of Ancient Kings", "Hammer of Justice", "Hammer of the Righteous", "Hand of Freedom", "Hand of Protection", "Hand of Purity", 
            "Hand of Sacrifice", "Hand of Salvation", "Holy Avenger", "Holy Prism", "Holy Shock", "Judgment", "Lay on Hands", "Light's Hammer", "Rebuke", "Reckoning", "Repentance", "Sacred Shield", "Speed of Light", "Turn Evil"
         };
        private static DateTime StopCastingCheckLast;
        private const string SVNURL = "https://tuanha.sourcerepo.com/tuanha/tuanhapaladinspecialedition.5.4/";
        private static readonly Stopwatch SW = new Stopwatch();
        private static int TotalUnitHolyRadiance;
        private static int TotalUnitHolyRadianceLightofDawn;
        private static WoWUnit UnitArcaneTorrent;
        private static WoWUnit UnitAttack;
        private static WoWUnit UnitAttackASAP;
        private static bool UnitAttackIsValid;
        private static WoWUnit UnitAttackPet;
        private static WoWPlayer UnitAutoRez;
        private static WoWUnit UnitAvengersShieldInterrupt;
        private static WoWUnit UnitAvengersShielLowestThreat;
        private static WoWUnit UnitBeaconAoE;
        private static WoWUnit UnitBeaconSet;
        private static DateTime UnitBeaconSetLast;
        private static WoWUnit UnitBestTarget;
        private static WoWUnit UnitBlindingLight;
        private static WoWUnit UnitCroudControlSurvive;
        private static WoWUnit UnitCrusaderStrike;
        private static WoWUnit UnitDevotionAuraSilence;
        private static WoWUnit UnitDispellerAround;
        private static WoWUnit UnitDoubleJeopardy;
        private static WoWUnit UnitEternalFlameBlanket;
        private static WoWUnit UnitExecutionSentenceHoly;
        private static WoWUnit UnitFriendlyTargeting;
        private static WoWUnit UnitHammerofJusticeEnemyLow;
        private static WoWUnit UnitHammerofJusticeEnemyUsingCD;
        private static WoWUnit UnitHammerofJusticeInterrupt;
        private static WoWUnit UnitHammerofWrath;
        private static WoWUnit UnitHandofFreedom;
        private static WoWUnit UnitHandofSalvHighThreat;
        private static WoWUnit UnitHasSacredShield;
        private static WoWUnit UnitHaveBeacon;
        private static WoWUnit UnitHaveMySacredShield;
        private static WoWUnit UnitHeal;
        private static bool UnitHealIsValid;
        private static WoWUnit UnitHolyPrismEnemyHeal;
        private static WoWUnit UnitHolyPrismFriendDPS;
        private static WoWUnit UnitHolyPrismHoly;
        private static WoWUnit UnitJudgment;
        private static WoWUnit UnitJudgmentSelflessHealerHoly;
        private static WoWUnit UnitRebuke;
        private static WoWUnit UnitReckoning;
        private static WoWUnit UnitReckoningProtection;
        private static WoWUnit UnitRepentance;
        private static WoWUnit UnitSacredShieldProt;
        private static WoWUnit UnitTankEternalFlame;
        private static WoWUnit UnitToBeaconOffTarget;
        private static WoWUnit UnitToSacredShield;
        private static WoWUnit UnitTurnEvil;
        private static WoWUnit UnitTurnEvilASAP;
        private static WoWUnit UnitWarStomp;
        private static int UseSpecialization;
        internal static string VersionBuild = "";

        private static bool AnyKeyPressed()
        {
            foreach (Keys keys in System.Enum.GetValues(typeof(Keys)))
            {
                if ((((((GetAsyncKeyState(keys) != 0) && (keys != Keys.Space)) && ((keys != Keys.LButton) && (keys != Keys.RButton))) && (((keys != Keys.None) && (keys != Keys.LWin)) && ((keys != Keys.RWin) && (keys != Keys.LShiftKey)))) && ((((keys != Keys.RShiftKey) && (keys != Keys.LControlKey)) && ((keys != Keys.RControlKey) && (keys != Keys.LMenu))) && (((keys != Keys.RMenu) && (keys != Keys.Tab)) && ((keys != Keys.Capital) && (keys != IndexToKeys(THSettings.Instance.StrafleLeft)))))) && ((((keys != IndexToKeys(THSettings.Instance.Forward)) && (keys != IndexToKeys(THSettings.Instance.StrafleRight))) && ((keys != IndexToKeys(THSettings.Instance.TurnLeft)) && (keys != IndexToKeys(THSettings.Instance.Backward)))) && (keys != IndexToKeys(THSettings.Instance.TurnRight))))
                {
                    return true;
                }
            }
            return false;
        }

        private static void ArcaneTorrentVoid()
        {
            if ((THSettings.Instance.AutoRacial && (LastInterrupt < DateTime.Now)) && (CanCastCheck("Arcane Torrent") && GetUnitArcaneTorrent()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitArcaneTorrent.IsCasting && (UnitArcaneTorrent.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitArcaneTorrent.IsChanneling)
                {
                    CastSpell("Arcane Torrent", (WoWUnit) Me, "Arcane Torrent");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite ArdentDefender()
        {
            return (Composite) new Decorator(ret => ((Me.Combat && (Me.HealthPercent <= THSettings.Instance.ArdentDefenderHP)) && !MeHasAura("Divine Shield")) && CanCastCheck("Ardent Defender"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Ardent Defender", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool Attackable(WoWUnit target, int range)
        {
            return (((((target != null) && target.IsValid) && (target.Attackable && target.CanSelect)) && ((target.IsAlive && (GetDistance(target) <= range)) && (!Invulnerable(target) && !DebuffCCBreakonDamage(target)))) && (IsEnemy(target) && (((range <= 5) || (GetDistance(target) <= 5f)) || InLineOfSpellSightCheck(target))));
        }

        private static bool AttackableNoCC(WoWUnit target, int range)
        {
            return ((((target != null) && target.IsValid) && (target.Attackable && target.CanSelect)) && (((target.IsAlive && (((target.Distance - target.CombatReach) - 1.0) <= range)) && (!Invulnerable(target) && IsEnemy(target))) && (((range <= 5) || (GetDistance(target) <= 5f)) || InLineOfSpellSightCheck(target))));
        }

        private static bool AttackableNoCCLoS(WoWUnit target, int range)
        {
            return ((((target != null) && target.IsValid) && (target.Attackable && target.CanSelect)) && ((target.IsAlive && (GetDistance(target) <= range)) && (!Invulnerable(target) && IsEnemy(target))));
        }

        private static bool AttackableNoLoS(WoWUnit target, int range)
        {
            return ((((target != null) && target.IsValid) && (target.Attackable && target.CanSelect)) && ((target.IsAlive && (GetDistance(target) <= range)) && ((!Invulnerable(target) && !DebuffCCBreakonDamage(target)) && IsEnemy(target))));
        }

        private static Composite AttackASAPRotationCastComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.Denounce && CanCastCheck("Denounce")) && (GetUnitAttackASAP() && !InvulnerableSpell(UnitAttackASAP))) && FacingOverride(UnitAttackASAP)) && Attackable(UnitAttackASAP, 30), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                WoWMovement.ConstantFace(UnitAttackASAP.Guid);
                CastSpell("Denounce", UnitAttackASAP, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite AttackASAPRotationInstantComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.CrusaderStrikeHoly && CanCastCheck("Crusader Strike")) && (GetUnitAttackASAP() && FacingOverride(UnitAttackASAP))) && Attackable(UnitAttackASAP, 5), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Crusader Strike", UnitAttackASAP, "");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.JudgmentHolyAttack && CanCastCheck("Judgment")) && (GetUnitAttackASAP() && !InvulnerableSpell(UnitAttackASAP))) && Attackable(UnitAttackASAP, 30 + _bonusJudgementRange), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", UnitAttackASAP, "GetUnitAttackASAP");
            })), (Composite) new Decorator(ret => (((HasGlyph.Contains("41107") && !SpellManager.HasSpell("Eternal Flame")) && ((PlayerHolyPower >= 1.0) || MeHasAura(" Divine Purpose"))) && (((UnitHealIsValid && (HealWeightUnitHeal > THSettings.Instance.WordofGloryHolyHP)) && (GetUnitAttackASAP() && !InvulnerableSpell(UnitAttackASAP))) && (FacingOverride(UnitAttackASAP) && CanCastCheck("Word of Glory")))) && Attackable(UnitAttackASAP, 40), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAttackASAP);
                CastSpell("Word of Glory", UnitAttackASAP, "");
            })), (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.Exorcism || !CanCastCheck("Exorcism")) || (!GetUnitAttackASAP() || !FacingOverride(UnitAttackASAP))) || (InvulnerableSpell(UnitAttackASAP) || ((PlayerHolyPower >= Me.MaxHolyPower) && (GetDistance(UnitAttackASAP) <= 5f))))
                {
                    return false;
                }
                return Attackable(UnitAttackASAP, 40);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAttackASAP);
                CastSpell("Exorcism", UnitAttackASAP, "");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.HolyShockOffensive && UnitHealIsValid) && ((HealWeightUnitHeal > THSettings.Instance.DoNotHealAbove) && CanCastCheck("Holy Shock"))) && ((GetUnitAttackASAP() && !InvulnerableSpell(UnitAttackASAP)) && FacingOverride(UnitAttackASAP))) && Attackable(UnitAttackASAP, 40), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAttackASAP);
                CastSpell("Holy Shock", UnitAttackASAP, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite AttackRotationHolyCastComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((((THSettings.Instance.Denounce && !IsMoving((WoWUnit) Me)) && (UnitHealIsValid && (HealWeightUnitHeal > THSettings.Instance.PriorityHeal))) && (UnitAttackIsValid && (UnitAttack.IsPlayer || (UnitAttack.HealthPercent < 30.0)))) && (((Me.ManaPercent > THSettings.Instance.ManaforDPS) || (UnitAttack.HealthPercent < 30.0)) || MeHasAura("Glyph of Denouce"))) && (CanCastCheck("Denounce") && !InvulnerableSpell(UnitAttack))) && Attackable(UnitAttack, 30), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                WoWMovement.ConstantFace(UnitAttack.Guid);
                CastSpell("Denounce", UnitAttack, "");
                UnitAttack = null;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite AttackRotationHolyInstantComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.JudgmentHolyAttack || THSettings.Instance.JudgmentLongArmoftheLaw) || THSettings.Instance.JudgmentBurdenofGuilt) && (((UnitHealIsValid && (HealWeightUnitHeal >= THSettings.Instance.PriorityHeal)) && ((Me.ManaPercent >= THSettings.Instance.ManaforDPS) && CanCastCheck("Judgment"))) && GetUnitJudgment())) && (UnitJudgment.Distance < (30 + _bonusJudgementRange)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", UnitJudgment, "JudgmentHolyAttack");
            })), (Composite) new Decorator(ret => (((((HasGlyph.Contains("41107") && !SpellManager.HasSpell("Eternal Flame")) && ((Me.ManaPercent >= THSettings.Instance.ManaforDPS) && UnitHealIsValid)) && ((UnitAttackIsValid && (HealWeightUnitHeal > THSettings.Instance.PriorityHeal)) && (HealWeightUnitHeal > THSettings.Instance.WordofGloryHolyHP))) && ((PlayerHolyPower >= 3.0) || MeHasAura(" Divine Purpose"))) && ((!InvulnerableSpell(UnitAttack) && FacingOverride(UnitAttack)) && CanCastCheck("Word of Glory"))) && Attackable(UnitAttack, 40), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAttack);
                CastSpell("Word of Glory", UnitAttack, "Glyph of Harsh Words");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.HolyShockOffensive && UnitHealIsValid) && ((HealWeightUnitHeal > THSettings.Instance.DoNotHealAbove) && (Me.ManaPercent >= THSettings.Instance.ManaforDPS))) && ((UnitAttackIsValid && CanCastCheck("Holy Shock")) && (!InvulnerableSpell(UnitAttack) && FacingOverride(UnitAttack)))) && Attackable(UnitAttack, 40), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAttack);
                CastSpell("Holy Shock", UnitAttack, "HolyShockOffensive");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite AutoRez()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (THSettings.Instance.AutoMove && ((UnitAutoRez.Distance > 40.0) || !UnitAutoRez.InLineOfSight))
                {
                    Navigator.MoveTo(UnitAutoRez.get_Location());
                }
                else if ((UnitAutoRez.Distance <= 40.0) && UnitAutoRez.InLineOfSight)
                {
                    if (IsMoving((WoWUnit) Me))
                    {
                        Navigator.get_PlayerMover().MoveStop();
                    }
                    CastSpell("Redemption", (WoWUnit) UnitAutoRez, "Redemption");
                    AutoRezListCacheAdd((WoWUnit) UnitAutoRez, 20);
                }
            }) };
            return (Composite) new Decorator(ret => ((THSettings.Instance.AutoRez && !Me.Combat) && CanCastCheck("Redemption")) && GetUnitAutoRez(), (Composite) new PrioritySelector(compositeArray));
        }

        private static void AutoRezListCacheAdd(WoWUnit unit, int expireSeconds = 20)
        {
            if (!AutoRezListCache.ContainsKey(unit.Guid))
            {
                AutoRezListCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromSeconds((double) expireSeconds));
            }
        }

        private static void AutoRezListCacheClear()
        {
            foreach (ulong num in (from unit in AutoRezListCache
                where unit.Value < DateTime.Now
                select unit.Key).ToList<ulong>())
            {
                AutoRezListCache.Remove(num);
            }
        }

        private static Composite AutoTarget()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (THSettings.Instance.AutoTarget && (LastAutoTarget <= DateTime.Now))
                {
                    if ((BasicCheck(Me.get_CurrentTarget()) && !CurrentTargetAttackableNoLoS(50.0)) && (GetBestTarget() && (Me.get_CurrentTarget() != UnitBestTarget)))
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    if (!BasicCheck(Me.get_CurrentTarget()) && GetBestTarget())
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Target  Best Unit");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite AutoTargetProt()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (THSettings.Instance.AutoTarget && (LastAutoTarget <= DateTime.Now))
                {
                    if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                    {
                        if ((BasicCheck(Me.get_CurrentTarget()) && !CurrentTargetAttackableNoLoS(50.0)) && (GetBestTarget() && (Me.get_CurrentTarget() != UnitBestTarget)))
                        {
                            UnitBestTarget.Target();
                            Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit");
                            LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                            return (RunStatus) RunStatus.Failure;
                        }
                        if (!BasicCheck(Me.get_CurrentTarget()) && GetBestTarget())
                        {
                            UnitBestTarget.Target();
                            Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Target  Best Unit");
                            LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                            return (RunStatus) RunStatus.Failure;
                        }
                    }
                    else if (GetBestTargetProt() && (Me.get_CurrentTarget() != UnitBestTarget))
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit Prot");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite AvengersShield()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AvengersShield && CurrentTargetAttackable(30.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && !CurrentTargetCheckInvulnerableMagic)) && CanCastCheck("Avenger's Shield"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Avenger's Shield", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite AvengersShieldGrandCrusader()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AvengersShield && MeHasAura("Grand Crusader")) && CurrentTargetAttackable(30.0, false, false)) && CanCastCheck("Avenger's Shield"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Avenger's Shield", Me.get_CurrentTarget(), "AvengersShieldGrandCrusader");
            }));
        }

        private void AvengersShieldInterruptVoid()
        {
            if ((THSettings.Instance.HammerofJusticeInterrupt && (LastInterrupt < DateTime.Now)) && (CanCastCheck("Avenger's Shield") && GetUnitAvengersShieldInterrupt()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                SafelyFacingTarget(UnitAvengersShieldInterrupt);
                if ((UnitAvengersShieldInterrupt.IsCasting && (UnitAvengersShieldInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitAvengersShieldInterrupt.IsChanneling)
                {
                    CastSpell("Avenger's Shield", UnitAvengersShieldInterrupt, "AvengersShieldInterrupt");
                    LastInterrupt = (DateTime.Now + TimeSpan.FromMilliseconds(1500.0)) + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite AvengersShieldLoseThreat()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AvengersShieldLowestThreat && Me.Combat) && CanCastCheck("Avenger's Shield")) && GetUnitReckoningProtection(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                SafelyFacingTarget(UnitReckoningProtection);
                CastSpell("Avenger's Shield", UnitReckoningProtection, "AvengersShieldLoseThreat");
            }));
        }

        private static Composite AvengersShieldLowestThreatUnit()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.AvengersShieldLowestThreat && CanCastCheck("Avenger's Shield")) && GetAvengersShieldLowestThreatUnit(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitAvengersShielLowestThreat);
                CastSpell("Avenger's Shield", UnitAvengersShielLowestThreat, "AvengersShieldLowestThreat");
            }));
        }

        private static Composite AvengingWrath()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AvengingWrathHoly || (LastBurstCalled >= DateTime.Now)) || (!UnitHealIsValid || (HealWeightUnitHeal > THSettings.Instance.AvengingWrathHolyHP))) || ((!UnitHeal.Combat || UnitHeal.IsPet) || (MeHasAura("Divine Shield") || !CanCastCheck("Avenging Wrath"))))
                {
                    return false;
                }
                if (THSettings.Instance.AvengingWrathHolyNumber > 1)
                {
                    return CountUnitHealthBelow(THSettings.Instance.AvengingWrathHolyHP) >= THSettings.Instance.AvengingWrathHolyNumber;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsCasting && !IsHealing())
                {
                    SpellManager.StopCasting();
                }
                LastBurstCalled = DateTime.Now + TimeSpan.FromSeconds((double) THSettings.Instance.BurstDelay);
                CastSpell("Avenging Wrath", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AvengingWrathBurstRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Burst && THSettings.Instance.AvengingWrath) && (CurrentTargetAttackable(15.0, false, false) && !Me.get_CurrentTarget().IsFlying)) && (CanCastCheck("Avenging Wrath") && (GetSpellCooldown("Guardian of Ancient Kings").TotalSeconds < 294.0))) && (GetSpellCooldown("Guardian of Ancient Kings").TotalSeconds > 0.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Avenging Wrath", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool BasicCheck(WoWUnit target)
        {
            return (((target != null) && target.IsValid) && target.IsAlive);
        }

        private static void BeaconAoE()
        {
            if ((((UseSpecialization == 1) && THSettings.Instance.BeaconofLight) && (HasGlyph.Contains("63218") && CanCastCheck("Beacon of Light"))) && (GetUnitBeaconAoE() && !MyAura("Beacon of Light", UnitBeaconAoE)))
            {
                CastSpell("Beacon of Light", UnitBeaconAoE, "BeaconAoE");
            }
        }

        private static void BeaconOffTarget(WoWUnit target)
        {
            if (((((UseSpecialization == 1) && THSettings.Instance.BeaconofLight) && (HasGlyph.Contains("63218") && CanCastCheck("Beacon of Light"))) && ((!GetUnitHaveBeacon() || (UnitHaveBeacon == target)) || (HealWeight(UnitHaveBeacon) >= 90.0))) && (GetUnitToBeaconOffTarget(target) && !MyAura("Beacon of Light", UnitToBeaconOffTarget)))
            {
                CastSpell("Beacon of Light", UnitToBeaconOffTarget, "BeaconOffTarget");
            }
        }

        private static Composite BeaconSet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BeaconofLight && (UnitBeaconSetLast < DateTime.Now)) && (!Me.Combat && UnitHealIsValid)) && (((HealWeightUnitHeal >= THSettings.Instance.DoNotHealAbove) && CanCastCheck("Beacon of Light")) && GetUnitBeaconSet())) && !MyAura("Beacon of Light", UnitBeaconSet), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Beacon of Light", UnitBeaconSet, "BeaconSet");
                UnitBeaconSetLast = DateTime.Now + TimeSpan.FromMilliseconds(5000.0);
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void BeaconTowerofRandiance(WoWUnit target)
        {
            if ((((UseSpecialization == 1) && THSettings.Instance.BeaconofLight) && (HasGlyph.Contains("63218") && SpellManager.HasSpell("Tower of Radiance"))) && (((PlayerHolyPower < Me.MaxHolyPower) && !MyAura("Beacon of Light", target)) && CanCastCheck("Beacon of Light")))
            {
                CastSpell("Beacon of Light", target, "BeaconTowerofRandiance");
            }
        }

        private void BlindingLightVoid()
        {
            if (((THSettings.Instance.BlindingLightInterrupt && (LastInterrupt < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal > THSettings.Instance.UrgentHeal))) && (CanCastCheck("Blinding Light") && GetUnitBlindingLight()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitBlindingLight.IsCasting && (UnitBlindingLight.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitBlindingLight.IsChanneling)
                {
                    CastSpell("Blinding Light", (WoWUnit) Me, "BlindingLight");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite BubbleFlashofLightRet()
        {
            return (Composite) new Decorator(ret => ((((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && (Me.HealthPercent < THSettings.Instance.DoNotHealAbove)) && ((MeHasAura("Divine Shield") || MeHasAura("Devotion Aura")) || MeHasAura("Hand of Protection"))) && (Me.CurrentMana > (Me.MaxMana * 0.378))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (IsMoving((WoWUnit) Me))
                {
                    Navigator.get_PlayerMover().MoveStop();
                    WoWMovement.MoveStop();
                }
                DoNotMove = DateTime.Now + TimeSpan.FromSeconds(1.0);
                CastSpell("Flash of Light", (WoWUnit) Me, "");
                if (DoNotMove < DateTime.Now)
                {
                    return (RunStatus) RunStatus.Running;
                }
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static bool BuffBurst(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => BuffBurstHS.Contains(aura.SpellId));
        }

        private static bool BuffEnrage(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!BuffEnrageHS.Contains(aura.SpellId))
                {
                    return (aura.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Enrage)));
                }
                return true;
            });
        }

        private static bool BuffHeal(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => BuffHealHS.Contains(aura.SpellId));
        }

        private static Composite BuffRotation()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.AutoBuff && THSettings.Instance.PreferMight) && (UnitHealIsValid && UnitHeal.IsPlayer)) && ((!UnitHasAura("Blessing of Might", UnitHeal) && !UnitHasAura("Grace of Air", UnitHeal)) && (!UnitHasAura("Roar of Courage", UnitHeal) && !UnitHasAura("Spirit Beast Blessing", UnitHeal)))) && CanCastCheck("Blessing of Might"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blessing of Might", (WoWUnit) Me, "Blessing of Might");
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.AutoBuff && THSettings.Instance.PreferMight) && (UnitHealIsValid && UnitHeal.IsPlayer)) && ((UnitHasAura("Blessing of Might", UnitHeal) || UnitHasAura("Grace of Air", UnitHeal)) || (UnitHasAura("Roar of Courage", UnitHeal) || UnitHasAura("Spirit Beast Blessing", UnitHeal)))) && (((!MyAura("Blessing of Might", UnitHeal) && !UnitHasAura("Spirit Beast Blessing", UnitHeal)) && (!UnitHasAura("Blessing of Kings", UnitHeal) && !UnitHasAura("Embrace of the Shale Spider", UnitHeal))) && (!UnitHasAura("Legacy of the Emperor", UnitHeal) && !UnitHasAura("Mark of the Wild", UnitHeal)))) && CanCastCheck("Blessing of Kings"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blessing of Kings", (WoWUnit) Me, "Blessing of Kings ");
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.AutoBuff && THSettings.Instance.PreferKings) && (UnitHealIsValid && UnitHeal.IsPlayer)) && ((!UnitHasAura("Spirit Beast Blessing", UnitHeal) && !UnitHasAura("Blessing of Kings", UnitHeal)) && (!UnitHasAura("Embrace of the Shale Spider", UnitHeal) && !UnitHasAura("Legacy of the Emperor", UnitHeal)))) && !UnitHasAura("Mark of the Wild", UnitHeal)) && CanCastCheck("Blessing of Kings"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blessing of Kings", (WoWUnit) Me, "Blessing of Kings ");
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.AutoBuff && THSettings.Instance.PreferKings) && (UnitHealIsValid && UnitHeal.IsPlayer)) && ((UnitHasAura("Spirit Beast Blessing", UnitHeal) || UnitHasAura("Blessing of Kings", UnitHeal)) || ((UnitHasAura("Embrace of the Shale Spider", UnitHeal) || UnitHasAura("Legacy of the Emperor", UnitHeal)) || UnitHasAura("Mark of the Wild", UnitHeal)))) && (((!MyAura("Blessing of Kings", UnitHeal) && !UnitHasAura("Blessing of Might", UnitHeal)) && (!UnitHasAura("Grace of Air", UnitHeal) && !UnitHasAura("Roar of Courage", UnitHeal))) && !UnitHasAura("Spirit Beast Blessing", UnitHeal))) && CanCastCheck("Blessing of Might"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blessing of Might", (WoWUnit) Me, "Blessing of Might");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static bool CanCastCheck(string spellName)
        {
            if (SpellManager.HasSpell(spellName))
            {
                WoWSpell spell;
                bool flag;
                double castTime;
                SpellsCooldownCacheClear();
                if (((UseSpecialization == 2) && SpellsCooldownCache.ContainsKey("Avenger's Shield")) && MeHasAura("Grand Crusader"))
                {
                    foreach (string str in (from unit in SpellsCooldownCache
                        where unit.Key == "Avenger's Shield"
                        select unit.Key).ToList<string>())
                    {
                        try
                        {
                            SpellsCooldownCache.Remove(str);
                            continue;
                        }
                        catch (Exception)
                        {
                            Styx.Common.Logging.Write("Fail to SpellsCooldownCache.Remove({0})", new object[] { str });
                            throw;
                        }
                    }
                }
                if (((UseSpecialization == 3) && SpellsCooldownCache.ContainsKey("Exorcism")) && MeHasAura("The Art of War"))
                {
                    foreach (string str2 in (from unit in SpellsCooldownCache
                        where unit.Key == "Exorcism"
                        select unit.Key).ToList<string>())
                    {
                        try
                        {
                            SpellsCooldownCache.Remove(str2);
                            continue;
                        }
                        catch (Exception)
                        {
                            Styx.Common.Logging.Write("Fail to SpellsCooldownCache.Remove({0})", new object[] { str2 });
                            throw;
                        }
                    }
                }
                if (SpellsCooldownCache.ContainsKey(spellName))
                {
                    return false;
                }
                if (OverrideToSpellHS.Contains(spellName) && SpellManager.HasSpell(OverrideToSpellId(spellName)))
                {
                    spell = WoWSpell.FromId(OverrideToSpellId(spellName));
                }
                else
                {
                    spell = SpellManager.get_Spells().get_Item(spellName);
                }
                if ((Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground) && (((spellName != "Divine Shield") && (spellName != "Every Man for Himself")) && ((spellName != "Hand of Protection") && DebuffCC((WoWUnit) Me))))
                {
                    return false;
                }
                double powerCost = spell.PowerCost;
                if ((Math.Abs((double) (powerCost - 1.0)) < 1.0) || (Math.Abs((double) (powerCost - 3.0)) < 1.0))
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
                if ((flag && !MeHasAura(0x1603e)) && (PlayerHolyPower < powerCost))
                {
                    return false;
                }
                if (!flag)
                {
                    if ((((spellName == "Flash of Light") || (spellName == "Divine Light")) || (spellName == "Holy Radiance")) && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 0.0))
                    {
                        powerCost -= (powerCost / 3.0) * MyAuraStackCount(0x1be4a, (WoWUnit) Me);
                    }
                    if (Me.CurrentMana < powerCost)
                    {
                        return false;
                    }
                }
                if (!IsMoving((WoWUnit) Me) || ((((spellName == "Flash of Light") || (spellName == "Divine Light")) || (spellName == "Holy Radiance")) && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 2.0)))
                {
                    castTime = 0.0;
                }
                else
                {
                    castTime = spell.CastTime;
                }
                if (castTime <= 0.0)
                {
                    spellCooldownBack = spell.CooldownTimeLeft.TotalMilliseconds;
                    if (spellCooldownBack <= 0.0)
                    {
                        return true;
                    }
                    if ((spellCooldownBack <= MyLatency) && (!Me.IsCasting || ((Me.IsCasting && (Me.CurrentCastTimeLeft.TotalMilliseconds <= MyLatency)) && (Me.CurrentChannelTimeLeft.TotalMilliseconds <= MyLatency))))
                    {
                        return true;
                    }
                    if (spellCooldownBack > MyLatency)
                    {
                        SpellsCooldownCacheAdd(spellName, DateTime.Now + TimeSpan.FromMilliseconds(spellCooldownBack - MyLatency));
                    }
                }
            }
            return false;
        }

        public static void CancelAura(int aura, WoWUnit target)
        {
            WoWAura auraById = target.GetAuraById(aura);
            if ((auraById != null) && auraById.Cancellable)
            {
                auraById.TryCancelAura();
            }
        }

        public static void CancelAura(string aura, WoWUnit target)
        {
            WoWAura auraByName = target.GetAuraByName(aura);
            if ((auraByName != null) && auraByName.Cancellable)
            {
                auraByName.TryCancelAura();
            }
        }

        private static Composite CancelBubbleProtection()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (!THSettings.Instance.AutoCancelBubble || ((!MeHasAura("Divine Shield") && !MeHasAura("Devotion Aura")) && !MeHasAura("Hand of Protection")))
                {
                    return false;
                }
                return Me.HealthPercent >= THSettings.Instance.AutoCancelBubbleHP;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CancelAura(0x282, (WoWUnit) Me);
                CancelAura(0x3fe, (WoWUnit) Me);
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool CanUseCheck(WoWItem Item)
        {
            ItemsCooldownCacheClear();
            if (!ItemsCooldownCache.ContainsKey(Item))
            {
                ItemCooldownBack = GetItemCooldown(Item);
                if (ItemCooldownBack.TotalMilliseconds <= 0.0)
                {
                    return true;
                }
                ItemsCooldownCacheAdd(Item, DateTime.Now + ItemCooldownBack);
            }
            return false;
        }

        private static bool CanUseEquippedItem(WoWItem item)
        {
            if (string.IsNullOrEmpty(Lua.GetReturnVal<string>("return GetItemSpell(" + item.Entry + ")", 0)))
            {
                return false;
            }
            return (item.Usable && (item.Cooldown <= 0f));
        }

        private static void CastSpell(string spellName, WoWUnit target, string reason = "")
        {
            try
            {
                SpellManager.Cast(spellName, target);
            }
            catch (Exception exception)
            {
                Styx.Common.Logging.Write(exception.ToString());
                throw;
            }
            LastCastSpell = spellName;
            LastCastUnit = target;
            LastCastTime = DateTime.Now;
            if (THSettings.Instance.AutoWriteLog && (LastWriteLog <= DateTime.Now))
            {
                LastWriteLog = DateTime.Now + TimeSpan.FromMilliseconds(MyLatency);
                if (((spellName == "Rebuke") || (spellName == "Hammer of Justice")) || (((spellName == "Fist of Justice") || (spellName == "Turn Evil")) || (spellName == "Blinding Light")))
                {
                    colorlog = Colors.GhostWhite;
                }
                else if (target == Me)
                {
                    colorlog = Colors.GreenYellow;
                }
                else if (target == Me.get_CurrentTarget())
                {
                    colorlog = Colors.Yellow;
                }
                else
                {
                    colorlog = Colors.YellowGreen;
                }
                Styx.Common.Logging.Write(colorlog, string.Concat(new object[] { 
                    DateTime.Now.ToString("ss:fff"), " HP: ", Math.Round(Me.HealthPercent), " % Mana: ", Math.Round(Me.ManaPercent), "  (", PlayerHolyPower, " HP) ", target.SafeName, " ", Math.Round(target.Distance, 2), "y ", Math.Round(target.HealthPercent), "% hp ", spellName, " (", 
                    reason, ")"
                 }));
            }
        }

        private static Composite CleanseFriendlyASAPComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.CleanseASAP && (((HealWeightUnitHeal >= THSettings.Instance.UrgentHeal) || Me.get_CurrentMap().IsDungeon) || (Me.get_CurrentMap().IsRaid || (Me.get_CurrentMap().Name == "Proving Grounds")))) && CanCastCheck("Cleanse")) && GetPlayerFriendlyCleanseASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SpellManager.StopCasting();
                CastSpell("Cleanse", PlayerFriendlyCleanseASAP, "CleanseFriendlyASAPComp");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite CleanseFriendlyComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.CleanseDebuff && UnitHealIsValid) && ((HealWeightUnitHeal > THSettings.Instance.PriorityHeal) && (Me.ManaPercent > 30.0))) && CanCastCheck("Cleanse")) && GetPlayerFriendlyCleanse(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Cleanse", PlayerFriendlyCleanse, "CleanseFriendlyComp");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite CleanseMe()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.CleanseDebuff || !UnitHealIsValid) || ((HealWeightUnitHeal <= THSettings.Instance.UrgentHeal) || (Me.ManaPercent <= 30.0))) || (!CanCastCheck("Cleanse") || (!DebuffRootCanCleanse((WoWUnit) Me) && (CountDebuff((WoWUnit) Me) < THSettings.Instance.CleanseDebuffNumber))))
                {
                    return false;
                }
                return !DebuffDoNotCleanse((WoWUnit) Me);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SpellManager.StopCasting();
                CastSpell("Cleanse", (WoWUnit) Me, "CleanseMe");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite Consecration()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((!THSettings.Instance.Consecration || !Me.Combat) || ((Me.ManaPercent <= 50.0) || !CanCastCheck("Consecration")))
                {
                    return false;
                }
                if (!CurrentTargetAttackable(10.0, false, false))
                {
                    return HasEnemyNear((WoWUnit) Me, 10f);
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Consecration", (WoWUnit) Me, "Consecration");
                if (HasGlyph.Contains("54928"))
                {
                    LastClickRemoteLocation = DateTime.Now + TimeSpan.FromMilliseconds(300.0);
                    while (LastClickRemoteLocation > DateTime.Now)
                    {
                        SpellManager.ClickRemoteLocation(Me.get_Location());
                    }
                }
            }));
        }

        private static Composite ConsecrationAoE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Consecration && Me.Combat) && ((Me.ManaPercent > 50.0) && CanCastCheck("Consecration"))) && (CountEnemyNear((WoWUnit) Me, 10f) >= 4.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Consecration", (WoWUnit) Me, "ConsecrationAoE");
                if (HasGlyph.Contains("54928"))
                {
                    LastClickRemoteLocation = DateTime.Now + TimeSpan.FromMilliseconds(300.0);
                    while (LastClickRemoteLocation > DateTime.Now)
                    {
                        SpellManager.ClickRemoteLocation(Me.get_Location());
                    }
                }
            }));
        }

        private static double CountDebuff(WoWUnit u)
        {
            if (((u == null) || !u.IsValid) || !u.IsAlive)
            {
                return 0.0;
            }
            return (double) u.get_Debuffs().Values.Count<WoWAura>(debuff => (((debuff.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Magic))) || (debuff.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Poison)))) || (((debuff.SpellId != 0xd726) && (debuff.SpellId != 0xd737)) && (debuff.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Disease))))));
        }

        private static double CountDebuffRootandSnareMechanic(WoWUnit u)
        {
            if (((u == null) || !u.IsValid) || !u.IsAlive)
            {
                return 0.0;
            }
            return (double) u.get_ActiveAuras().Values.Count<WoWAura>(delegate (WoWAura debuff) {
                if (debuff.get_Spell().get_Mechanic() != ((WoWSpellMechanic) ((int) WoWSpellMechanic.Snared)))
                {
                    return (debuff.get_Spell().get_Mechanic() == ((WoWSpellMechanic) ((int) WoWSpellMechanic.Rooted)));
                }
                return true;
            });
        }

        private static int CountDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => ((((unit.IsValid && unit.GotTarget) && (unit.get_CurrentTarget() == target)) && ((((TalentSort(unit) >= 2) && (TalentSort(unit) <= 3)) && (unit.get_Location().Distance(target.get_Location()) < 40f)) || ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) < 15f)))) && !DebuffCC(unit)) && ((target != Me) || ((target == Me) && InLineOfSpellSightCheck(unit)));
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => ((unit.IsValid && unit.GotTarget) && (unit.get_CurrentTarget() == target)) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static double CountEnemyNear(WoWUnit unitCenter, float distance)
        {
            return (double) FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(delegate (WoWUnit unit) {
                if ((!(Me.get_CurrentMap().Name == "Proving Grounds") && !IsDummy(unit)) && ((!unit.Combat || (unit.MaxHealth <= (MeMaxHealth * 0.2))) || (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return (GetDistance(unitCenter, unit) <= distance);
            });
        }

        private static double CountEnemyTargettingUnit(WoWUnit target, float distance)
        {
            return (double) NearbyUnFriendlyUnits.Count<WoWUnit>(delegate (WoWUnit unit) {
                if (((!unit.IsValid || (GetDistance(unit) >= distance)) || (!unit.GotTarget || (unit.Level > (target.Level + 3)))) || ((unit.IsPet || (unit.get_CurrentTarget() != target)) || DebuffCC(unit)))
                {
                    return false;
                }
                return ((target != Me) || ((target == Me) && InLineOfSpellSightCheck(unit)));
            });
        }

        private static int CountFriendTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            if (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)
            {
                return NearbyFriendlyPlayers.Count<WoWUnit>(unit => ((unit.IsValid && unit.GotTarget) && (unit.get_CurrentTarget() == target)));
            }
            if (predicate == null)
            {
                predicate = delegate (WoWUnit unit) {
                    if ((!BasicCheck(unit) || !unit.GotTarget) || (unit.get_CurrentTarget() != target))
                    {
                        return false;
                    }
                    return ((TalentSort(unit) >= 2) && (unit.get_Location().Distance(target.get_Location()) < 40f)) || ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) < 15f));
                };
            }
            return NearbyFriendlyPlayers.Count<WoWUnit>(predicate);
        }

        private static int CountMeleeDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = delegate (WoWUnit unit) {
                        if (((!unit.IsValid || !unit.GotTarget) || ((unit.get_CurrentTarget() != target) || (TalentSort(unit) != 1))) || ((unit.get_Location().Distance(target.get_Location()) >= 15f) || DebuffCC(unit)))
                        {
                            return false;
                        }
                        return (target != Me) || ((target == Me) && InLineOfSpellSightCheck(unit));
                    };
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => ((unit.IsValid && unit.GotTarget) && ((unit.get_CurrentTarget() == target) && (unit.get_Location().Distance(target.get_Location()) < 15f))) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static int CountPhysicDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => ((((unit.IsValid && unit.GotTarget) && (unit.get_CurrentTarget() == target)) && (((TalentSort(unit) == 2) && (unit.get_Location().Distance(target.get_Location()) < 40f)) || ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) < 25f)))) && !DebuffCC(unit)) && ((target != Me) || ((target == Me) && InLineOfSpellSightCheck(unit)));
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => ((unit.IsValid && unit.GotTarget) && ((unit.get_CurrentTarget() == target) && (unit.get_Location().Distance(target.get_Location()) < 15f))) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static double CountUnitHealthBelow(int HealthPercent)
        {
            return (double) NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(unit => (HealWeight(unit) <= HealthPercent));
        }

        private static double CountUnitHolyPrism(WoWUnit unitCenter)
        {
            return (double) FarFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(unit => ((unitCenter.get_Location().Distance(unit.get_Location()) <= 15f) && (HealWeight(unit) <= THSettings.Instance.HolyPrismEnemyHealHP)));
        }

        private static double CountUnitHolyPrismFriendDPS(WoWUnit unitCenter)
        {
            return (double) NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(unit => ((!unit.IsPet && !DebuffCCBreakonDamage(unit)) && (unitCenter.get_Location().Distance(unit.get_Location()) <= 15f)));
        }

        private static double CountUnitHolyRadiance(WoWUnit unitCenter)
        {
            TotalUnitHolyRadiance = 0;
            foreach (WoWUnit unit in NearbyFriendlyPlayers)
            {
                if ((BasicCheck(unit) && (unitCenter.get_Location().Distance(unit.get_Location()) <= 10f)) && (HealWeight(unit) <= THSettings.Instance.HolyRadianceHP))
                {
                    if (DebuffDoNotHeal(unit))
                    {
                        TotalUnitHolyRadiance -= 0x3e8;
                    }
                    TotalUnitHolyRadiance++;
                }
            }
            return (double) TotalUnitHolyRadiance;
        }

        private static double CountUnitLightofDawn()
        {
            TotalUnitHolyRadianceLightofDawn = 0;
            foreach (WoWUnit unit in NearbyFriendlyPlayers)
            {
                if ((BasicCheck(unit) && (unit.Distance <= 30.0)) && (HealWeight(unit) <= THSettings.Instance.LightofDawnHP))
                {
                    if (DebuffDoNotHeal(unit))
                    {
                        TotalUnitHolyRadianceLightofDawn -= 0x3e8;
                    }
                    TotalUnitHolyRadianceLightofDawn++;
                }
            }
            return (double) TotalUnitHolyRadianceLightofDawn;
        }

        private static double CountUnitLightsHammer(WoWUnit unitCenter)
        {
            return (double) NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(unit => ((unitCenter.get_Location().Distance(unit.get_Location()) <= 10f) && (HealWeight(unit) <= THSettings.Instance.LightsHammerFriendHP)));
        }

        internal static string CreateMD5Hash(string input)
        {
            byte[] bytes = Encoding.ASCII.GetBytes(input);
            return BitConverter.ToString(MD5.Create().ComputeHash(bytes)).Replace("-", "").ToLower();
        }

        private static Composite CrowdControlHPSurviveComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.HammerofJusticeLow && CanCastCheck("Fist of Justice")) && GetUnitCroudControlSurvive(20f, (double) THSettings.Instance.HammerofJusticeLowHP)) && !InvulnerableStun(UnitCroudControlSurvive), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Fist of Justice", UnitCroudControlSurvive, "Fist of Justice Survive");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.HammerofJusticeLow && CanCastCheck("Hammer of Justice")) && GetUnitCroudControlSurvive(10f, (double) THSettings.Instance.HammerofJusticeLowHP)) && !InvulnerableStun(UnitCroudControlSurvive), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Hammer of Justice", UnitCroudControlSurvive, "Hammer of Justice Survive");
            })), (Composite) new Decorator(ret => (THSettings.Instance.BlindingLightLow && CanCastCheck("Blinding Light")) && GetUnitCroudControlSurvive(10f, (double) THSettings.Instance.BlindingLightLowHP), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blinding Light", UnitCroudControlSurvive, "BlindingLightLow");
                Lua.DoString("RunMacroText('/stopattack');", "WoW.lua");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite CrusaderStrikeHoly()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.CrusaderStrikeHoly && !MeHasAura("Hand of Protection")) && (Me.Combat && (PlayerHolyPower < Me.MaxHolyPower))) && (CanCastCheck("Crusader Strike") && GetUnitCrusaderStrikeHoly())) && Me.IsFacing((WoWObject) UnitCrusaderStrike), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitCrusaderStrike);
                CastSpell("Crusader Strike", UnitCrusaderStrike, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite CrusaderStrikeProt()
        {
            return (Composite) new Decorator(ret => ((((CurrentTargetAttackable(5.0, false, false) && !CurrentTargetCheckInvulnerablePhysic) && (!MeHasAura("Divine Purposes") && !MeHasAura("Hand of Protection"))) && (!THSettings.Instance.ShieldofRighterous || (PlayerHolyPower < Me.MaxHolyPower))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Crusader Strike"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Crusader Strike", Me.get_CurrentTarget(), "CrusaderStrikeProt");
            }));
        }

        private static Composite CrusaderStrikeRet()
        {
            return (Composite) new Decorator(ret => (((CurrentTargetAttackable(5.0, false, false) && !CurrentTargetCheckInvulnerablePhysic) && (!MeHasAura("Divine Purposes") && !MeHasAura("Hand of Protection"))) && (FacingOverride(Me.get_CurrentTarget()) && (PlayerHolyPower < Me.MaxHolyPower))) && CanCastCheck("Crusader Strike"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Crusader Strike", Me.get_CurrentTarget(), "CrusaderStrikeRet");
            }));
        }

        private static bool CurrentTargetAttackable(double distance, bool includeCurrentTargetCheckInvulnerableePhysic = false, bool includeCurrentTargetCheckInvulnerableeMagic = false)
        {
            if (((Me.get_CurrentTarget() == null) || !Me.get_CurrentTarget().IsValid) || (!Me.get_CurrentTarget().Attackable || !Me.get_CurrentTarget().IsAlive))
            {
                return false;
            }
            if (Me.get_CurrentTarget() != CurrentTargetCheckLast)
            {
                CurrentTargetCheck();
            }
            return (((((CurrentTargetCheckIsEnemy && !CurrentTargetCheckDebuffCCBreakonDamage) && !CurrentTargetCheckInvulnerable) && ((CurrentTargetCheckFacing || THSettings.Instance.AutoFace) || !IsOverrideModeOn)) && (!includeCurrentTargetCheckInvulnerableePhysic || !CurrentTargetCheckInvulnerablePhysic)) && ((!includeCurrentTargetCheckInvulnerableeMagic || !CurrentTargetCheckInvulnerableMagic) && ((CurrentTargetCheckDist <= distance) && CurrentTargetCheckInLineOfSpellSight)));
        }

        private static bool CurrentTargetAttackableNoLoS(double distance)
        {
            if (((Me.get_CurrentTarget() == null) || !Me.get_CurrentTarget().IsValid) || (!Me.get_CurrentTarget().Attackable || !Me.get_CurrentTarget().IsAlive))
            {
                return false;
            }
            if (Me.get_CurrentTarget() != CurrentTargetCheckLast)
            {
                CurrentTargetCheck();
            }
            return ((!CurrentTargetCheckDebuffCCBreakonDamage && !CurrentTargetCheckInvulnerable) && (CurrentTargetCheckIsEnemy && (CurrentTargetCheckDist <= distance)));
        }

        private static void CurrentTargetCheck()
        {
            if (CurrentTargetCheckLastTime <= DateTime.Now)
            {
                CurrentTargetCheckLastTime = DateTime.Now + CurrentTargetCheckTimeOut;
                if (BasicCheck(Me.get_CurrentTarget()))
                {
                    CurrentTargetCheckLast = Me.get_CurrentTarget();
                    CurrentTargetCheckFacing = Me.IsSafelyFacing((WoWObject) Me.get_CurrentTarget(), 180f);
                    CurrentTargetCheckDist = GetDistance(Me.get_CurrentTarget());
                    CurrentTargetCheckIsEnemy = IsEnemy(Me.get_CurrentTarget());
                    if (CurrentTargetCheckIsEnemy)
                    {
                        CurrentTargetCheckInvulnerable = Invulnerable(Me.get_CurrentTarget());
                        if (!CurrentTargetCheckInvulnerable)
                        {
                            CurrentTargetCheckDebuffCCBreakonDamage = DebuffCCBreakonDamage(Me.get_CurrentTarget());
                            if (!CurrentTargetCheckDebuffCCBreakonDamage)
                            {
                                CurrentTargetCheckInvulnerableMagic = InvulnerableSpell(Me.get_CurrentTarget());
                                CurrentTargetCheckInvulnerablePhysic = InvulnerablePhysic(Me.get_CurrentTarget());
                                if (CurrentTargetCheckDist <= 5.0)
                                {
                                    CurrentTargetCheckInLineOfSpellSight = true;
                                }
                                else if (InLineOfSpellSightCheck(Me.get_CurrentTarget()))
                                {
                                    CurrentTargetCheckInLineOfSpellSight = true;
                                }
                            }
                        }
                    }
                }
            }
        }

        private static Composite DeathRotation()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Waiting up to {0} seconds for clear area to use {1}...", new object[] { 10, SelfRezSpell });
            }), (Composite) new Wait(10, delegate (object until) {
                MobsNearby = CountEnemyNear((WoWUnit) Me, 20f);
                if ((MobsNearby > 0.0) && !Me.IsAlive)
                {
                    return Me.IsGhost;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                if (Me.IsGhost)
                {
                    Styx.Common.Logging.Write("Insignia taken or corpse release by something other than Singular...");
                    return (RunStatus) RunStatus.Failure;
                }
                if (Me.IsAlive)
                {
                    Styx.Common.Logging.Write("Ressurected by something other than Singular...");
                    return (RunStatus) RunStatus.Failure;
                }
                return (RunStatus) RunStatus.Success;
            })), (Composite) new DecoratorContinue(req => MobsNearby > 0.0, (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Still {0} enemies within {1} yds, skipping {2}", new object[] { MobsNearby, 20, SelfRezSpell });
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Ressurrecting Singular by invoking {0}...", new object[] { SelfRezSpell });
            }), (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Lua.DoString("UseSoulstone()", "WoW.lua");
            }), (Composite) new WaitContinue(1, delegate (object until) {
                if (!Me.IsAlive)
                {
                    return Me.IsGhost;
                }
                return true;
            }, (Composite) new ActionAlwaysSucceed()) };
            return (Composite) new Decorator(delegate (object req) {
                if (Me.IsAlive || Me.IsGhost)
                {
                    return false;
                }
                List<string> returnValues = Lua.GetReturnValues("return HasSoulstone()", "hawker.lua");
                if (((returnValues == null) || (returnValues.Count == 0)) || (string.IsNullOrEmpty(returnValues[0]) || (returnValues[0].ToLower() == "nil")))
                {
                    return false;
                }
                if (!THSettings.Instance.AutoMove)
                {
                    if (NextSuppressMessage < DateTime.Now)
                    {
                        NextSuppressMessage = DateTime.Now.AddSeconds(10.0);
                        Styx.Common.Logging.Write("Suppressing {0} behavior since movement disabled...", new object[] { returnValues[0] });
                    }
                    return false;
                }
                SelfRezSpell = returnValues[0];
                return true;
            }, (Composite) new Sequence(compositeArray));
        }

        private Composite DeathSelector()
        {
            if (this._deathBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing death behaviours.");
                this._deathBehavior = (Composite) new PrioritySelector(new Composite[] { DeathRotation() });
            }
            return null;
        }

        private static bool DebuffCC(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCHS.Contains(aura.SpellId));
        }

        private static bool DebuffCCBreakonDamage(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCBreakonDamageHS.Contains(aura.SpellId));
        }

        private static bool DebuffCCDuration(WoWUnit target, double duration, bool LogSpell = false)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffCCDurationHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffCCleanseASAP(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid || (Me.get_CurrentMap().Name == "Proving Grounds"))
            {
                return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCleanseASAPPvEHS.Contains(aura.SpellId));
            }
            if ((target.IsPlayer && (target.get_Class() == ((WoWClass) ((uint) WoWClass.Warrior)))) && target.GetAllAuras().Any<WoWAura>(aura => DebuffCCleanseASAPHSWarrior.Contains(aura.SpellId)))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffCCleanseASAPPvPHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds > 3000.0)));
        }

        private static bool DebuffDisarm(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return (target.Disarmed || target.GetAllAuras().Any<WoWAura>(aura => DebuffDisarmHS.Contains(aura.SpellId)));
        }

        private static bool DebuffDoNotCleanse(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffDoNotCleanseHS.Contains(aura.SpellId));
        }

        private static bool DebuffDoNotHeal(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffDoNotHealHS.Contains(aura.SpellId));
        }

        private static bool DebuffDot(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!aura.IsHarmful)
                {
                    return false;
                }
                if (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamagePercent)));
                }
                return true;
            });
        }

        private static double DebuffDotCount(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0.0;
            }
            return (double) target.GetAllAuras().Count<WoWAura>(aura => (aura.IsHarmful && (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))));
        }

        private static bool DebuffDotDuration(WoWUnit target, int duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.IsHarmful && (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffFearDuration(WoWUnit target, double duration)
        {
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if ((!DebuffFearDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModFear)))) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModCharm))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds > duration);
            });
        }

        private static bool DebuffMagicCCDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffMagicCCDurationHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffRoot(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot)));
                }
                return true;
            });
        }

        private static bool DebuffRootCanCleanse(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootCanCleanseHS.Contains(aura.SpellId))
                {
                    if (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot)))
                    {
                        return false;
                    }
                    if (aura.get_Spell().get_DispelType() != ((WoWDispelType) ((int) WoWDispelType.Magic)))
                    {
                        return (aura.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Poison)));
                    }
                }
                return true;
            });
        }

        private static bool DebuffRootCanCloak(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffRootCanCloakHS.Contains(aura.SpellId));
        }

        private static bool DebuffRootDuration(WoWUnit target, int duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds > duration);
            });
        }

        private static bool DebuffRootorSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootorSnareHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static int DebuffRootorSnareCount(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0;
            }
            return target.GetAllAuras().Count<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootorSnareHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static bool DebuffSilence(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffSilenceHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModSilence)));
                }
                return true;
            });
        }

        private static bool DebuffSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffSnareHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static bool DebuffStun(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun)));
                }
                return true;
            });
        }

        private static bool DebuffStunDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds >= duration);
            });
        }

        private static double DebuffStunDurationTimeLeft(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0.0;
            }
            WoWAura aura = (from aura in target.GetAllAuras()
                orderby aura.TimeLeft descending
                select aura).FirstOrDefault<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId))
                {
                    return aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun));
                }
                return true;
            });
            if (aura == null)
            {
                return 0.0;
            }
            return aura.TimeLeft.TotalMilliseconds;
        }

        private static bool DebuffStunFearDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if ((!DebuffStunFearDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun)))) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModFear))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds >= duration);
            });
        }

        internal static string Decrypt(string cipherText, string passPhrase)
        {
            byte[] bytes = Encoding.ASCII.GetBytes("www.tuanha.biz/l");
            byte[] buffer = Convert.FromBase64String(cipherText);
            byte[] rgbKey = new PasswordDeriveBytes(passPhrase, null).GetBytes(0x20);
            ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(rgbKey, bytes);
            MemoryStream stream = new MemoryStream(buffer);
            CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
            byte[] buffer4 = new byte[buffer.Length];
            int count = stream2.Read(buffer4, 0, buffer4.Length);
            stream.Close();
            stream2.Close();
            return Encoding.UTF8.GetString(buffer4, 0, count);
        }

        private static Composite DevotionAura()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.DevotionAura && (Me.HealthPercent <= THSettings.Instance.DevotionAuraHP)) && (Me.Combat && !MeHasAura("Divine Shield"))) && !MeHasAura("Devotion Aura")) && CanCastCheck("Devotion Aura"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Devotion Aura", (WoWUnit) Me, "DevotionAura");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (THSettings.Instance.DevotionAuraSilence && CanCastCheck("Devotion Aura")) && GetUnitDevotionAuraSilence(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Devotion Aura", (WoWUnit) Me, "DevotionAuraSilence");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite Dismount()
        {
            return (Composite) new Decorator(ret => ((IsUsingAFKBot && (Me.Combat || Me.get_CurrentMap().IsBattleground)) && ((Me.Mounted && !Me.IsFlying) && !IsMoving((WoWUnit) Me))) && HasEnemyNear((WoWUnit) Me, 30f), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Mount.Dismount("Stuck on mount? Dismounting for combat.");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DivineFavor()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.DivineFavor || (LastBurstCalled >= DateTime.Now)) || (!UnitHealIsValid || (HealWeightUnitHeal > THSettings.Instance.DivineFavorHP))) || ((!UnitHeal.Combat || UnitHeal.IsPet) || (MeHasAura("Divine Shield") || !CanCastCheck("Divine Favor"))))
                {
                    return false;
                }
                if (THSettings.Instance.DivineFavorNumber > 1)
                {
                    return CountUnitHealthBelow(THSettings.Instance.DivineFavorHP) >= THSettings.Instance.DivineFavorNumber;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsCasting && !IsHealing())
                {
                    SpellManager.StopCasting();
                }
                LastBurstCalled = DateTime.Now + TimeSpan.FromSeconds((double) THSettings.Instance.BurstDelay);
                CastSpell("Divine Favor", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DivineLight()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.DivineLight && UnitHealIsValid) && (HealWeightUnitHeal <= THSettings.Instance.DivineLightHP)) && (Me.Combat || UnitHeal.Combat)) && ((!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground) && (!MeHasAura(0x1603e) && (PlayerHolyPower < Me.MaxHolyPower)))) && CanCastCheck("Divine Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Divine Light", UnitHeal, "DivineLight");
            }));
        }

        private static Composite DivineLightBubble()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DivineLight && (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)) && ((MeHasAura("Divine Shield") || MeHasAura("Devotion Aura")) || MeHasAura("Hand of Protection"))) && ((UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.DoNotHealAbove)) && MeHasAura(0xd385))) && CanCastCheck("Divine Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Divine Light", UnitHeal, "DivineLightBubble");
            }));
        }

        private static Composite DivineLightProc()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.DivineLight && MeHasAura(0xd385)) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.DivineLightHP))) && (Me.Combat || UnitHeal.Combat)) && (!MeHasAura(0x1603e) && (PlayerHolyPower < Me.MaxHolyPower))) && CanCastCheck("Divine Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Divine Light", UnitHeal, "DivineLightProc");
            }));
        }

        private static Composite DivinePlea()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.DivinePlea || MeHasAura("Arena Preparation")) || MeHasAura("Preparation")) || ((Me.ManaPercent > THSettings.Instance.DivinePleaHP) && (((UseSpecialization != 1) || (Me.ManaPercent >= 70.0)) || (!Me.get_CurrentMap().IsRaid || !MeHasAura("Hymn of Hope"))))) || ((!UnitHealIsValid || (HealWeightUnitHeal <= THSettings.Instance.UrgentHeal)) && (Me.ManaPercent >= 10.0)))
                {
                    return false;
                }
                return CanCastCheck("Divine Plea");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Divine Plea", (WoWUnit) Me, "");
            }));
        }

        private static Composite DivineProtection()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.DivineProtection && Me.Combat) && ((Me.HealthPercent <= THSettings.Instance.DivineProtectionHP) && !MeHasAura("Divine Shield"))) && CanCastCheck("Divine Protection"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Divine Protection", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DivineShield()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.DivineShield && Me.Combat) && (!MeHasAura("Forbearance") && !MeHasAura("Alliance Flag"))) && ((!MeHasAura("Horde Flag") && !MeHasAura("Netherstorm Flag")) && (!MeHasAura("Orb of Power") && !MeHasAura("Ardent Defender")))) && ((Me.HealthPercent <= THSettings.Instance.DivineShieldHP) && CanCastCheck("Divine Shield"))) && (CountEnemyTargettingUnit((WoWUnit) Me, 40f) > 0.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Divine Shield", (WoWUnit) Me, "DivineShield");
            }));
        }

        private static Composite DivineStorm3HolyPower()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DivineStorm && !MeHasAura("Hand of Protection")) && ((MyAuraTimeLeft(0x14be3, (WoWUnit) Me) > 7000.0) && CurrentTargetAttackable(5.0, false, false))) && (!CurrentTargetCheckInvulnerableMagic && CanCastCheck("Divine Storm"))) && (CountEnemyNear((WoWUnit) Me, 8f) >= THSettings.Instance.DivineStormUnit), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Divine Storm", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite DivineStorm5HolyPower()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.DivineStorm && !MeHasAura("Hand of Protection")) && (CurrentTargetAttackable(5.0, false, false) && !CurrentTargetCheckInvulnerableMagic)) && (((PlayerHolyPower >= Me.MaxHolyPower) || MeHasAura(0x1603e)) || ((PlayerHolyPower >= 3.0) && MeHasAura("Holy Avenger")))) && CanCastCheck("Divine Storm")) && (CountEnemyNear((WoWUnit) Me, 8f) >= THSettings.Instance.DivineStormUnit), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Divine Storm", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite Emancipate()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.Emancipate && CurrentTargetAttackable(60.0, false, false)) && ((GetDistance(Me.get_CurrentTarget()) > 5f) && !MeHasAura("Hand of Freedom"))) && (!THSettings.Instance.HandofFreedomMyself || !SpellManager.HasSpell("Hand of Freedom"))) && DebuffRootorSnare((WoWUnit) Me)) && CanCastCheck("Emancipate"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Emancipate", (WoWUnit) Me, "Emancipate");
            }));
        }

        internal static string Encrypt(string plainText, string passPhrase)
        {
            byte[] bytes = Encoding.UTF8.GetBytes("www.tuanha.biz/l");
            byte[] buffer = Encoding.UTF8.GetBytes(plainText);
            byte[] rgbKey = new PasswordDeriveBytes(passPhrase, null).GetBytes(0x20);
            ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateEncryptor(rgbKey, bytes);
            MemoryStream stream = new MemoryStream();
            CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Write);
            stream2.Write(buffer, 0, buffer.Length);
            stream2.FlushFinalBlock();
            byte[] inArray = stream.ToArray();
            stream.Close();
            stream2.Close();
            return Convert.ToBase64String(inArray);
        }

        private static void EnemyListCacheAdd(WoWUnit unit, int expireSeconds = 10)
        {
            if ((!MeHasAura("Arena Preparation") && !MeHasAura("Preparation")) && !EnemyListCache.ContainsKey(unit.Guid))
            {
                EnemyListCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromSeconds((double) expireSeconds));
            }
        }

        private static void EnemyListCacheClear()
        {
            if (EnemyListCacheClearLast <= DateTime.Now)
            {
                EnemyListCacheClearLast = DateTime.Now + TimeSpan.FromSeconds(5.0);
                foreach (ulong num in (from unit in EnemyListCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<ulong>())
                {
                    EnemyListCache.Remove(num);
                }
            }
        }

        private static Composite EternalFlame()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.WordofGloryHoly || !UnitHealIsValid) || ((PlayerHolyPower < 3.0) && !MeHasAura(0x1603e))) || (((HealWeightUnitHeal > THSettings.Instance.WordofGloryHolyHP) && (!MeHasAura(0x1603e) || (MyAuraTimeLeft(0x1603e, (WoWUnit) Me) >= 3000.0))) && ((HealWeightUnitHeal > THSettings.Instance.HolyLightHP) || (PlayerHolyPower <= 4.0))))
                {
                    return false;
                }
                return CanCastCheck("Eternal Flame");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconAoE();
                CastSpell("Eternal Flame", UnitHeal, "EternalFlame");
            }));
        }

        private static Composite EternalFlameBlanket()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.EternalFlameBlanket && ((PlayerHolyPower >= THSettings.Instance.EternalFlameBlanketHolyPower) || MeHasAura(0x1603e))) && CanCastCheck("Eternal Flame")) && GetUnitEternalFlameBlanket(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconAoE();
                CastSpell("Eternal Flame", UnitEternalFlameBlanket, "EternalFlameBlanket");
            }));
        }

        private static Composite EternalFlameTank()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.WordofGloryHoly && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && CanCastCheck("Eternal Flame")) && GetUnitTankEternalFlame(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconAoE();
                CastSpell("Eternal Flame", UnitTankEternalFlame, "EternalFlameTank");
            }));
        }

        private static Composite ExecutionSentence()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.ExecutionSentenceFriend && UnitHealIsValid) && ((HealWeightUnitHeal <= THSettings.Instance.ExecutionSentenceFriendHP) && UnitHeal.Combat)) && CanCastCheck("Execution Sentence"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Execution Sentence", UnitHeal, "ExecutionSentenceFriend");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ExecutionSentenceEnemy && (UseSpecialization != 1)) && (CurrentTargetAttackable(40.0, false, false) && !CurrentTargetCheckInvulnerableMagic)) && ((!Me.get_CurrentTarget().IsPet && FacingOverride(Me.get_CurrentTarget())) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.ExecutionSentenceEnemyHP))) && CanCastCheck("Execution Sentence"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Execution Sentence", Me.get_CurrentTarget(), "ExecutionSentenceEnemy");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.ExecutionSentenceEnemy && (UseSpecialization == 1)) && CanCastCheck("Execution Sentence")) && GetUnitExecutionSentenceHoly(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitExecutionSentenceHoly);
                CastSpell("Execution Sentence", UnitExecutionSentenceHoly, "UnitExecutionSentenceHoly");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite Exorcism()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Exorcism && (CurrentTargetAttackable(5.0, false, false) || (!HasGlyph.Contains("122028") && CurrentTargetAttackable(30.0, false, false)))) && ((!CurrentTargetCheckInvulnerableMagic && FacingOverride(Me.get_CurrentTarget())) && ((PlayerHolyPower < Me.MaxHolyPower) || (GetDistance(Me.get_CurrentTarget()) > 5f)))) && CanCastCheck("Exorcism"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Exorcism", Me.get_CurrentTarget(), "Exorcism");
            }));
        }

        private static bool FacingOverride(WoWUnit unit)
        {
            if (!BasicCheck(unit))
            {
                return false;
            }
            if ((!Me.IsSafelyFacing((WoWObject) unit, 180f) && (!Me.IsMoving || !Me.IsSafelyFacing((WoWObject) unit, 220f))) && (!THSettings.Instance.AutoFace || IsOverrideModeOn))
            {
                return false;
            }
            return true;
        }

        private static Composite FlashofLight()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.FlashofLightHoly && UnitHealIsValid) && (HealWeightUnitHeal <= THSettings.Instance.FlashofLightHolyHP)) && (Me.Combat || UnitHeal.Combat)) && (!MeHasAura(0x1603e) && (PlayerHolyPower < Me.MaxHolyPower))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Flash of Light", UnitHeal, "");
            }));
        }

        private static Composite FlashofLightBubble()
        {
            return (Composite) new Decorator(ret => (((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && ((MeHasAura("Divine Shield") || MeHasAura("Devotion Aura")) || MeHasAura("Hand of Protection"))) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.DoNotHealAbove))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Flash of Light", UnitHeal, "FlashofLightBubble");
            }));
        }

        private static Composite FlashofLightFriendRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FlashofLightFriendRet && (FlashofLightDPSSpec < DateTime.Now)) && (!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid)) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.FlashofLightFriendRetHP))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                CastSpell("Flash of Light", UnitHeal, "FlashofLightFriendRet");
            }));
        }

        private static Composite FlashofLightMeRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FlashofLightMeRet && (FlashofLightDPSSpec < DateTime.Now)) && (!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid)) && (Me.HealthPercent <= THSettings.Instance.FlashofLightMeRetHP)) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                CastSpell("Flash of Light", (WoWUnit) Me, "FlashofLightMeRet");
            }));
        }

        private static Composite FlashofLightMeTopUpRet()
        {
            return (Composite) new Decorator(ret => ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && ((((FlashofLightDPSSpec < DateTime.Now) && UnitHealIsValid) && (!UnitHeal.Combat && (HealWeightUnitHeal < THSettings.Instance.DoNotHealAbove))) && CanCastCheck("Flash of Light"))) && (CountDPSTarget((WoWUnit) Me) == 0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                CastSpell("Flash of Light", UnitHeal, "FlashofLightMeTopUpRet");
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static Composite FlashofLightSelflessHealer()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.SelflessHealer && UnitHealIsValid) && ((HealWeightUnitHeal <= THSettings.Instance.SelflessHealerHP) && (FlashofLightDPSSpec < DateTime.Now))) && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 2.0)) && CanCastCheck("Divine Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Divine Light", UnitHeal, "FlashofLightSelflessHealer");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.SelflessHealer && UnitHealIsValid) && ((HealWeightUnitHeal <= THSettings.Instance.SelflessHealerHP) && (FlashofLightDPSSpec < DateTime.Now))) && (!SpellManager.HasSpell("Divine Light") && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 2.0))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Flash of Light", UnitHeal, "FlashofLightSelflessHealer");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite FlashofLightSelflessHealerExpiring()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.SelflessHealer && (FlashofLightDPSSpec < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.DoNotHealAbove))) && ((MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 2.0) && (MyAuraTimeLeft(0x1be4a, (WoWUnit) Me) < 3000.0))) && CanCastCheck("Divine Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Divine Light", UnitHeal, "FlashofLightSelflessHealerExpiring");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.SelflessHealer && (FlashofLightDPSSpec < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.DoNotHealAbove))) && (((MyAuraStackCount(0x1be4a, (WoWUnit) Me) > 2.0) && (MyAuraTimeLeft(0x1be4a, (WoWUnit) Me) < 3000.0)) && !SpellManager.HasSpell("Divine Light"))) && CanCastCheck("Flash of Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FlashofLightDPSSpec = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                BeaconTowerofRandiance(UnitHeal);
                CastSpell("Flash of Light", UnitHeal, "FlashofLightSelflessHealerExpiring");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static void FriendListCacheAdd(WoWUnit unit, int expireSeconds = 60)
        {
            if (!FriendListCache.ContainsKey(unit.Guid))
            {
                FriendListCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromSeconds((double) expireSeconds));
            }
        }

        private static void FriendListCacheClear()
        {
            if (FriendListCacheClearLast <= DateTime.Now)
            {
                FriendListCacheClearLast = DateTime.Now + TimeSpan.FromSeconds(5.0);
                foreach (ulong num in (from unit in FriendListCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<ulong>())
                {
                    FriendListCache.Remove(num);
                }
            }
        }

        private static IEnumerable<WoWUnit> GetAllUnits()
        {
            return ObjectManager.GetObjectsOfType<WoWUnit>(true, true);
        }

        [DllImport("user32.dll")]
        private static extern short GetAsyncKeyState(Keys vKey);
        private static bool GetAvengersShieldLowestThreatUnit()
        {
            UnitAvengersShielLowestThreat = null;
            UnitAvengersShielLowestThreat = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.get_ThreatInfo().RawPercent
                select unit).FirstOrDefault<WoWUnit>(unit => (((Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid) && (((Me.Combat && unit.Combat) && FacingOverride(unit)) && ((Me.get_CurrentMap().Name == "Proving Grounds") || (unit.GotTarget && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))) && (!UnitHasAura("Vengeance", unit.get_CurrentTarget()) && (GetDistance(unit) < 30f))) && InLineOfSpellSightCheck(unit));
            return BasicCheck(UnitAvengersShielLowestThreat);
        }

        private static bool GetBestTarget()
        {
            UnitBestTarget = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                if (DebuffRootorSnare((WoWUnit) Me))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 5));
                }
                else
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 20));
                }
                if (UnitBestTarget == null)
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 60));
                }
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 5);
                });
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 20);
                });
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 40);
                });
            }
            return BasicCheck(UnitBestTarget);
        }

        private static bool GetBestTargetProt()
        {
            UnitBestTarget = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                if (DebuffRootorSnare((WoWUnit) Me))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 5));
                }
                else
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 20));
                }
                if (UnitBestTarget == null)
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 60));
                }
            }
            else
            {
                WoWUnit target = null;
                if (Me.get_CurrentMap().Name == "Proving Grounds")
                {
                    target = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => unit.GetThreatInfoFor((WoWUnit) Me).RawPercent < 100);
                }
                if (BasicCheck(target))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.get_ThreatInfo().RawPercent
                        select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 5));
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 10));
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 20));
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 40));
                    }
                }
                else
                {
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 5);
                        });
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 20);
                        });
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 40);
                        });
                    }
                }
            }
            return BasicCheck(UnitBestTarget);
        }

        public static string GetCurrentSpec()
        {
            switch (Me.get_Specialization())
            {
                case WoWSpec.PaladinHoly:
                    CurrentSpec = "Holy";
                    break;

                case WoWSpec.PaladinProtection:
                    CurrentSpec = "Protection";
                    break;

                default:
                    CurrentSpec = "Retribution";
                    break;
            }
            return CurrentSpec;
        }

        private static float GetDistance(WoWUnit target)
        {
            if ((target == null) || !target.IsValid)
            {
                return 10000f;
            }
            if (target.CombatReach < 3f)
            {
                return (float) target.Distance;
            }
            return ((((float) target.Distance) - target.CombatReach) + 1f);
        }

        private static float GetDistance(WoWUnit source, WoWUnit target)
        {
            if (((source == null) || !source.IsValid) || ((target == null) || !target.IsValid))
            {
                return 10000f;
            }
            if (target.CombatReach < 3f)
            {
                return source.get_Location().Distance(target.get_Location());
            }
            return ((source.get_Location().Distance(target.get_Location()) - target.CombatReach) + 1f);
        }

        private static bool GetEnemyLightsHammer()
        {
            EnemyLightsHammer = null;
            EnemyLightsHammer = (from unit in NearbyFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby CountEnemyNear(unit, 10f) descending
                select unit).FirstOrDefault<WoWUnit>(unit => (CountEnemyNear(unit, 10f) >= THSettings.Instance.LightsHammerEnemyNumber) && Attackable(unit, 30));
            return BasicCheck(EnemyLightsHammer);
        }

        private static TimeSpan GetItemCooldown(WoWItem Item)
        {
            if ((Item != null) && Item.Usable)
            {
                return Item.CooldownTimeLeft;
            }
            return TimeSpan.FromMinutes(1.0);
        }

        private static int GetLocalRevision()
        {
            string path = LocalFolder + @"\.svn";
            if (Directory.Exists(path))
            {
                int num = -2147483648;
                string str2 = Directory.GetFiles(path, "wc.db").FirstOrDefault<string>();
                if (!string.IsNullOrEmpty(str2))
                {
                    byte[] bytes = System.IO.File.ReadAllBytes(str2);
                    string input = Encoding.Default.GetString(bytes);
                    Regex regex = new Regex("/!svn/ver/(?'version'[0-9]*)/");
                    foreach (Match match in regex.Matches(input))
                    {
                        int num2;
                        if (int.TryParse(match.Groups["version"].Value, out num2) && (num2 > num))
                        {
                            num = num2;
                        }
                    }
                    if (num > -2147483648)
                    {
                        return num;
                    }
                }
            }
            return 0;
        }

        private static bool GetMyHandonUnit(WoWUnit target)
        {
            if (!BasicCheck(target))
            {
                return false;
            }
            return target.get_ActiveAuras().Any<KeyValuePair<string, WoWAura>>(a => ((a.Value.CreatorGuid == Me.Guid) && MyHandHS.Contains(a.Value.SpellId)));
        }

        private static bool GetPlayerFriendlyCleanse()
        {
            PlayerFriendlyCleanse = null;
            if ((THSettings.Instance.CleanseDebuffNumber == 0) || !Me.Combat)
            {
                return false;
            }
            PlayerFriendlyCleanse = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountDebuff)).FirstOrDefault<WoWUnit>(unit => (!DebuffDoNotCleanse(unit) && (CountDebuff(unit) >= THSettings.Instance.CleanseDebuffNumber)) && Healable(unit, 40));
            return BasicCheck(PlayerFriendlyCleanse);
        }

        private static bool GetPlayerFriendlyCleanseASAP()
        {
            PlayerFriendlyCleanseASAP = null;
            if (!THSettings.Instance.CleanseASAP || !Me.Combat)
            {
                return false;
            }
            PlayerFriendlyCleanseASAP = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (DebuffCCleanseASAP(unit) && !DebuffDoNotCleanse(unit)) && Healable(unit, 40));
            return BasicCheck(PlayerFriendlyCleanseASAP);
        }

        private static bool GetPlayerFriendlyHandofSacASAP()
        {
            PlayerFriendlyHandofSacASAP = null;
            PlayerFriendlyHandofSacASAP = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((((THSettings.Instance.HandofSacCCRemoveHealer && (TalentSort(unit) == 4)) || (THSettings.Instance.HandofSacCCRemoveCaster && ((TalentSort(unit) == 2) || (TalentSort(unit) == 3)))) || (THSettings.Instance.HandofSacCCRemoveMelee && (TalentSort(unit) == 1))) && (DebuffMagicCCDuration(unit, 3000.0) && !DebuffDoNotCleanse(unit))) && Healable(unit, 40));
            return BasicCheck(PlayerFriendlyHandofSacASAP);
        }

        private static bool GetPlayerHandofProtectionFriendRemoveCC()
        {
            PlayerHandofProtectionFriendRemoveCC = null;
            PlayerHandofProtectionFriendRemoveCC = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((UnitHasAura("Blind", unit) || UnitHasAura("Intimidation Shout", unit)) && (((!UnitHasAura("Forbearance", unit) && !UnitHasAura("Alliance Flag", unit)) && (!UnitHasAura("Horde Flag", unit) && !UnitHasAura("Netherstorm Flag", unit))) && !UnitHasAura("Orb of Power", unit))) && ((unit != Me) || ((unit == Me) && (SpellManager.get_Spells().get_Item("Divine Shield").CooldownTimeLeft.TotalSeconds > 60.0))));
            return BasicCheck(PlayerHandofProtectionFriendRemoveCC);
        }

        private static bool GetPlayerHandofPurityDebuff()
        {
            PlayerHandofPurityDebuff = null;
            PlayerHandofPurityDebuff = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.DebuffDotCount)).FirstOrDefault<WoWUnit>(unit => ((!GetMyHandonUnit(unit) && !Invulnerable(unit)) && (DebuffDotCount(unit) >= THSettings.Instance.HandofPurityDebuffNumber)) && Healable(unit, 40));
            return BasicCheck(PlayerHandofPurityDebuff);
        }

        private static bool GetPlayerHolyRadiance()
        {
            PlayerHolyRadiance = null;
            PlayerHolyRadiance = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountUnitHolyRadiance)).FirstOrDefault<WoWUnit>(unit => (CountUnitHolyRadiance(unit) >= THSettings.Instance.HolyRadianceNumber) && Healable(unit, 40));
            return BasicCheck(PlayerHolyRadiance);
        }

        private static bool GetPlayerLightsHammer()
        {
            PlayerLightsHammer = null;
            PlayerLightsHammer = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountUnitLightsHammer)).FirstOrDefault<WoWUnit>(unit => ((GetDistance(unit) < 30f) && (CountUnitLightsHammer(unit) >= THSettings.Instance.LightsHammerFriendNumber)) && Healable(unit, 40));
            return BasicCheck(PlayerLightsHammer);
        }

        private static double GetSpellCastTime(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return 99999.9;
            }
            if (results.Override == null)
            {
                return (((double) results.Original.CastTime) / 1000.0);
            }
            return (((double) results.Override.CastTime) / 1000.0);
        }

        private static double GetSpellCastTime(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return 99999.9;
            }
            if (results.Override == null)
            {
                return (((double) results.Original.CastTime) / 1000.0);
            }
            return (((double) results.Override.CastTime) / 1000.0);
        }

        private static TimeSpan GetSpellCooldown(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return TimeSpan.MaxValue;
            }
            if (results.Override == null)
            {
                return results.Original.CooldownTimeLeft;
            }
            return results.Override.CooldownTimeLeft;
        }

        private static TimeSpan GetSpellCooldown(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return TimeSpan.MaxValue;
            }
            if (results.Override == null)
            {
                return results.Original.CooldownTimeLeft;
            }
            return results.Override.CooldownTimeLeft;
        }

        private static double GetSpellPowerCost(int spell)
        {
            SpellFindResults results;
            if (SpellManager.FindSpell(spell, ref results))
            {
                return ((results.Override != null) ? ((double) results.Override.PowerCost) : ((double) results.Original.PowerCost));
            }
            return 99999.9;
        }

        private static double GetSpellPowerCost(string spell)
        {
            SpellFindResults results;
            if (SpellManager.FindSpell(spell, ref results))
            {
                return ((results.Override != null) ? ((double) results.Override.PowerCost) : ((double) results.Original.PowerCost));
            }
            return 99999.9;
        }

        private static int GetSVNRevision()
        {
            string input = new WebClient().DownloadString("https://tuanha.sourcerepo.com/tuanha/tuanhapaladinspecialedition.5.4/");
            Match match = new Regex(@" - Revision (?<rev>\d+):", RegexOptions.CultureInvariant).Match(input);
            if (!match.Success || !match.Groups["rev"].Success)
            {
                throw new Exception("Unable to retreive revision");
            }
            return int.Parse(match.Groups["rev"].Value);
        }

        private static bool GetUnitArcaneTorrent()
        {
            UnitArcaneTorrent = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitArcaneTorrent = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false)) && Attackable(unit, 8));
            }
            else
            {
                UnitArcaneTorrent = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || FarFriendlyUnits.Contains(unit.get_CurrentTarget())) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false))) && Attackable(unit, 8));
            }
            return BasicCheck(UnitArcaneTorrent);
        }

        private static Composite GetUnitAttack()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                UnitAttack = null;
                UnitAttackPet = null;
                if (UseSpecialization != 1)
                {
                    UnitAttack = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                        if (!unit.Combat || (((!unit.IsTargetingMeOrPet && !unit.IsTargetingMyPartyMember) && !unit.IsTargetingMyRaidMember) && ((!Me.get_CurrentMap().IsBattleground && !Me.get_CurrentMap().IsArena) || !unit.IsPlayer)))
                        {
                            return false;
                        }
                        return Attackable(unit, 40);
                    });
                }
                else
                {
                    UnitAttack = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.HealthPercent
                        select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                        if (!unit.Combat || (((!unit.IsTargetingMeOrPet && !unit.IsTargetingMyPartyMember) && !unit.IsTargetingMyRaidMember) && ((!Me.get_CurrentMap().IsBattleground && !Me.get_CurrentMap().IsArena) || !unit.IsPlayer)))
                        {
                            return false;
                        }
                        return Attackable(unit, 40);
                    });
                }
                if (((UnitAttack != null) && !UnitAttack.IsPlayer) && (!Me.get_CurrentMap().IsRaid && !Me.get_CurrentMap().IsDungeon))
                {
                    UnitAttackPet = UnitAttack;
                    UnitAttack = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                        if ((!unit.Combat || !unit.IsTargetingMeOrPet) && !Me.get_CurrentMap().IsBattleground)
                        {
                            return false;
                        }
                        return Attackable(unit, 40);
                    });
                    if ((UnitAttack == null) && (UnitAttackPet != null))
                    {
                        UnitAttack = UnitAttackPet;
                    }
                }
                if (BasicCheck(UnitAttack))
                {
                    UnitAttackIsValid = true;
                }
                else
                {
                    UnitAttackIsValid = false;
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static bool GetUnitAttackASAP()
        {
            if (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)
            {
                return false;
            }
            UnitAttackASAP = null;
            if (UnitAttackASAP == null)
            {
                UnitAttackASAP = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((unit.get_Class() == ((WoWClass) ((uint) WoWClass.Rogue))) || (unit.get_Class() == ((WoWClass) ((uint) WoWClass.Druid)))) && !DebuffDot(unit)) && Attackable(unit, 40));
            }
            if (UnitAttackASAP == null)
            {
                UnitAttackASAP = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!unit.IsTotem || ((((unit.Entry != 0xcf0e) && (unit.Entry != 0xec91)) && ((unit.Entry != 0xa46) && (unit.Entry != 0xe945))) && (((unit.Entry != 0x28e3) && (unit.Entry != 0xe974)) && (unit.Entry != 0xef3d))))
                    {
                        return false;
                    }
                    return Attackable(unit, 40);
                });
            }
            return BasicCheck(UnitAttackASAP);
        }

        private static bool GetUnitAutoRez()
        {
            AutoRezListCacheClear();
            UnitAutoRez = null;
            UnitAutoRez = ObjectManager.GetObjectsOfType<WoWPlayer>(false, false).FirstOrDefault<WoWPlayer>(p => ((!AutoRezListCache.ContainsKey(p.Guid) && p.IsPlayer) && (!p.IsAlive && (p.Distance < 100.0))) && p.IsInMyPartyOrRaid);
            return ((UnitAutoRez != null) && UnitAutoRez.IsValid);
        }

        private static bool GetUnitAvengersShieldInterrupt()
        {
            UnitAvengersShieldInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitAvengersShieldInterrupt = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (FacingOverride(unit) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false))) && Attackable(unit, 30));
            }
            else
            {
                UnitAvengersShieldInterrupt = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (((FacingOverride(unit) && ((Me.get_CurrentMap().Name == "Proving Grounds") || (unit.GotTarget && FarFriendlyUnits.Contains(unit.get_CurrentTarget())))) && ((unit.get_CurrentTarget() == Me) || !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false))) && Attackable(unit, 30));
            }
            return BasicCheck(UnitAvengersShieldInterrupt);
        }

        private static bool GetUnitBeaconAoE()
        {
            UnitBeaconAoE = null;
            UnitBeaconAoE = FarFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((HealWeight(unit) >= 90.0) && (!Me.get_CurrentMap().IsRaid || !IsTank(unit)))
                {
                    return false;
                }
                return InLineOfSpellSightCheck(unit);
            });
            return BasicCheck(UnitBeaconAoE);
        }

        private static bool GetUnitBeaconSet()
        {
            UnitBeaconSet = null;
            if ((Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid) || (Me.get_CurrentMap().Name == "Proving Grounds"))
            {
                UnitBeaconSet = (from unit in FarFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.MaxHealth descending
                    select unit).FirstOrDefault<WoWUnit>(new Func<WoWUnit, bool>(Classname.InLineOfSpellSightCheck));
            }
            else
            {
                UnitBeaconSet = (WoWUnit) Me;
            }
            return BasicCheck(UnitBeaconSet);
        }

        private static bool GetUnitBlindingLight()
        {
            UnitBlindingLight = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitBlindingLight = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && InterruptCheck(unit, (double) THSettings.Instance.BlindingLightInterruptMs, false)) && Attackable(unit, 5));
            }
            else
            {
                UnitBlindingLight = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((unit.Combat && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || FarFriendlyUnits.Contains(unit.get_CurrentTarget())) && InterruptCheck(unit, (double) THSettings.Instance.BlindingLightInterruptMs, false))) && Attackable(unit, 5));
            }
            return BasicCheck(UnitBlindingLight);
        }

        private static bool GetUnitCroudControlSurvive(float distance, double FriendHPPercent)
        {
            UnitCroudControlSurvive = null;
            UnitCroudControlSurvive = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.CurrentHealth descending
                select unit).FirstOrDefault<WoWUnit>(unit => (((((unit.Level <= (Me.Level + 3)) && unit.Combat) && (!unit.IsPet && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) && (((HealWeight(unit.get_CurrentTarget()) <= FriendHPPercent) && !Invulnerable(unit.get_CurrentTarget())) && (!UnitHasAura("Hand of Protection", unit.get_CurrentTarget()) && !DebuffCC(unit)))) && (!InvulnerableSpell(unit) && (GetDistance(unit) <= distance))) && InLineOfSpellSightCheck(unit));
            return BasicCheck(UnitCroudControlSurvive);
        }

        private static bool GetUnitCrusaderStrikeHoly()
        {
            UnitCrusaderStrike = null;
            UnitCrusaderStrike = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => FacingOverride(unit) && Attackable(unit, 5));
            return BasicCheck(UnitCrusaderStrike);
        }

        private static bool GetUnitDevotionAuraSilence()
        {
            UnitDevotionAuraSilence = null;
            UnitDevotionAuraSilence = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((HealWeight(unit) > THSettings.Instance.DevotionAuraSilenceHP) || ((!THSettings.Instance.DevotionAuraSilenceAny && (!THSettings.Instance.DevotionAuraSilenceHealer || (TalentSort(unit) != 4))) && (!THSettings.Instance.DevotionAuraSilenceCaster || (TalentSort(unit) != 3))))
                {
                    return false;
                }
                return DebuffSilence(unit);
            });
            return BasicCheck(UnitDevotionAuraSilence);
        }

        private static bool GetUnitDispellerAround()
        {
            UnitDispellerAround = null;
            UnitDispellerAround = (from unit in (from unit in NearbyUnFriendlyUnits
                orderby unit.Distance
                where unit.IsPlayer
                select unit).Where<WoWUnit>(delegate (WoWUnit unit) {
                if (((unit.get_Class() != ((WoWClass) ((uint) WoWClass.Hunter))) && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Mage)))) && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Priest))))
                {
                    return unit.get_Class() == ((WoWClass) ((uint) WoWClass.Shaman));
                }
                return true;
            })
                where AttackableNoLoS(unit, 40)
                select unit).FirstOrDefault<WoWUnit>();
            return BasicCheck(UnitDispellerAround);
        }

        private static bool GetUnitDoubleJeopardy()
        {
            UnitDoubleJeopardy = null;
            UnitDoubleJeopardy = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby MyAuraTimeLeft(0x7c3b, unit)
                select unit).FirstOrDefault<WoWUnit>(unit => ((Me.Combat && (((Me.get_CurrentMap().Name == "Proving Grounds") || ((unit.Combat && unit.GotTarget) && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) || IsDummy(unit))) && !InvulnerableSpell(unit)) && Attackable(unit, 30 + _bonusJudgementRange));
            return BasicCheck(UnitDoubleJeopardy);
        }

        private static bool GetUnitEternalFlameBlanket()
        {
            UnitEternalFlameBlanket = null;
            UnitEternalFlameBlanket = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => !MyAura("Eternal Flame", unit) && Healable(unit, 40));
            return BasicCheck(UnitEternalFlameBlanket);
        }

        private static bool GetUnitExecutionSentenceHoly()
        {
            UnitExecutionSentenceHoly = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                UnitExecutionSentenceHoly = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.HealthPercent
                    select unit).FirstOrDefault<WoWUnit>(unit => (((unit.HealthPercent <= THSettings.Instance.ExecutionSentenceEnemyHP) && FacingOverride(unit)) && !InvulnerableSpell(unit)) && Attackable(unit, 40));
            }
            else
            {
                UnitExecutionSentenceHoly = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.HealthPercent descending
                    select unit).FirstOrDefault<WoWUnit>(unit => (((unit.HealthPercent <= THSettings.Instance.ExecutionSentenceEnemyHP) && FacingOverride(unit)) && !InvulnerableSpell(unit)) && Attackable(unit, 40));
            }
            return BasicCheck(UnitExecutionSentenceHoly);
        }

        private static bool GetUnitHammerofJusticeEnemyLow()
        {
            UnitHammerofJusticeEnemyLow = null;
            UnitHammerofJusticeEnemyLow = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.HealthPercent
                select unit).FirstOrDefault<WoWUnit>(unit => (((Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.PaladinHoly))) || ((Me.get_CurrentTarget() != null) && (unit == Me.get_CurrentTarget()))) && ((((unit.HealthPercent <= THSettings.Instance.HammerofJusticeEnemyLowHP) && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.DeathKnight)))) && ((TalentSort(unit) != 4) && !InvulnerableStun(unit))) && !InvulnerableSpell(unit))) && (Attackable(unit, 10) || (SpellManager.HasSpell("Fist of Justice") && Attackable(unit, 20))));
            return BasicCheck(UnitHammerofJusticeEnemyLow);
        }

        private static bool GetUnitHammerofJusticeEnemyUsingCD()
        {
            UnitHammerofJusticeEnemyUsingCD = null;
            UnitHammerofJusticeEnemyUsingCD = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.HealthPercent descending
                select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((InvulnerableStun(unit) || InvulnerableSpell(unit)) || !BuffBurst(unit))
                {
                    return false;
                }
                return Attackable(unit, 10) || (SpellManager.HasSpell("Fist of Justice") && Attackable(unit, 20));
            });
            return BasicCheck(UnitHammerofJusticeEnemyUsingCD);
        }

        private static bool GetUnitHammerofJusticeInterrupt()
        {
            UnitHammerofJusticeInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitHammerofJusticeInterrupt = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && ((InterruptCheck(unit, (double) THSettings.Instance.HammerofJusticeInterruptMs, true) && !InvulnerableSpell(unit)) && !InvulnerableStun(unit))) && ((SpellManager.HasSpell("Fist of Justice") && Attackable(unit, 20)) || Attackable(unit, 10)));
            }
            else
            {
                UnitHammerofJusticeInterrupt = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || FarFriendlyUnits.Contains(unit.get_CurrentTarget())) && InterruptCheck(unit, (double) THSettings.Instance.HammerofJusticeInterruptMs, true))) && ((SpellManager.HasSpell("Fist of Justice") && Attackable(unit, 20)) || Attackable(unit, 10)));
            }
            return BasicCheck(UnitHammerofJusticeInterrupt);
        }

        private static bool GetUnitHammerofWrath()
        {
            UnitHammerofWrath = null;
            UnitHammerofWrath = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && (GetDistance(unit) <= 30f)) && ((unit.HealthPercent <= 20.0) && !Invulnerable(unit))) && FacingOverride(unit)) && InLineOfSpellSightCheck(unit));
            return BasicCheck(UnitHammerofWrath);
        }

        private static bool GetUnitHandofFreedom()
        {
            UnitHandofFreedom = null;
            if (THSettings.Instance.HandofFreedomMelee)
            {
                UnitHandofFreedom = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((((GetDistance(unit) < 30f) && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Paladin)))) && ((unit.get_Class() != ((WoWClass) ((uint) WoWClass.Druid))) && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Shaman))))) && (((TalentSort(unit) == 1) && (HealWeight(unit) > 30.0)) && (!GetMyHandonUnit(unit) && !DebuffCC(unit)))) && ((DebuffRootorSnare(unit) && IsEnemy(unit.get_CurrentTarget())) && (unit.get_Location().Distance(unit.get_CurrentTarget().get_Location()) > 6f))) && Healable(unit, 40));
            }
            if ((UnitHandofFreedom == null) && THSettings.Instance.HandofFreedomHealer)
            {
                UnitHandofFreedom = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((((GetDistance(unit) < 30f) && (TalentSort(unit) == 4)) && ((HealWeight(unit) > 10.0) && !GetMyHandonUnit(unit))) && ((!DebuffCC(unit) && DebuffRootorSnare(unit)) && HasEnemyMeleeTarget(unit, 10))) && Healable(unit, 40));
            }
            if ((UnitHandofFreedom == null) && THSettings.Instance.HandofFreedomCaster)
            {
                UnitHandofFreedom = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((((GetDistance(unit) < 30f) && (TalentSort(unit) > 1)) && ((TalentSort(unit) < 4) && !GetMyHandonUnit(unit))) && ((!DebuffCC(unit) && DebuffRootorSnare(unit)) && HasEnemyMeleeTarget(unit, 10))) && Healable(unit, 40));
            }
            return BasicCheck(UnitHandofFreedom);
        }

        private static bool GetUnitHandofSalvHighThreat()
        {
            UnitHandofSalvHighThreat = null;
            UnitHandofSalvHighThreat = (from unit in NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby Me.get_CurrentTarget().GetThreatInfoFor(unit).ThreatValue descending
                select unit).FirstOrDefault<WoWUnit>(unit => ((unit.Combat && !UnitHasAura("Vengeance", unit)) && ((Me.get_CurrentTarget().GetThreatInfoFor(unit).RawPercent >= THSettings.Instance.HandofSalvHighThreatPercent) && !GetMyHandonUnit(unit))) && Healable(unit, 40));
            return BasicCheck(UnitHandofSalvHighThreat);
        }

        private static void GetUnitHasSacredShield()
        {
            UnitHasSacredShield = null;
            UnitHasSacredShield = FarFriendlyUnits.FirstOrDefault<WoWUnit>(unit => MyAura("Sacred Shield", unit));
        }

        private static bool GetUnitHaveBeacon()
        {
            UnitHaveBeacon = FarFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => BasicCheck(unit) && MyAura("Beacon of Light", unit));
            return BasicCheck(UnitHaveBeacon);
        }

        private static bool GetUnitHaveMySacredShield()
        {
            UnitHaveMySacredShield = null;
            UnitHaveMySacredShield = (from unit in FarFriendlyPlayers
                where MyAura(0x51bd, unit)
                select unit).FirstOrDefault<WoWUnit>();
            return BasicCheck(UnitHaveMySacredShield);
        }

        private static Composite GetUnitHeal()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                UnitHeal = null;
                UnitHealIsValid = false;
                HealWeightUnitHeal = 10000.0;
                if (((((UnitHeal == null) && (Me.get_CurrentTarget() != null)) && (Me.get_CurrentTarget().IsValid && Me.get_CurrentTarget().IsAlive)) && ((GetDistance(Me.get_CurrentTarget()) < 40f) && ((Me.get_CurrentTarget().IsPlayer || Me.get_CurrentTarget().IsPet) || NeedHealUnit(Me.get_CurrentTarget())))) && (((Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.DoNotHealAbove) && !IsEnemy(Me.get_CurrentTarget())) && (!DebuffDoNotHeal(Me.get_CurrentTarget()) && InLineOfSpellSightCheck(Me.get_CurrentTarget()))))
                {
                    UnitHeal = Me.get_CurrentTarget();
                }
                if (((((UnitHeal == null) && (Me.get_FocusedUnit() != null)) && (Me.get_FocusedUnit().IsValid && Me.get_FocusedUnit().IsAlive)) && ((GetDistance(Me.get_FocusedUnit()) < 40f) && ((Me.get_FocusedUnit().IsPlayer || Me.get_FocusedUnit().IsPet) || NeedHealUnit(Me.get_FocusedUnit())))) && (((Me.get_FocusedUnit().HealthPercent <= THSettings.Instance.PriorityHeal) && !IsEnemy(Me.get_FocusedUnit())) && (!DebuffDoNotHeal(Me.get_FocusedUnit()) && InLineOfSpellSightCheck(Me.get_FocusedUnit()))))
                {
                    UnitHeal = Me.get_FocusedUnit();
                }
                if ((!Me.get_CurrentMap().IsArena && (Me.get_CurrentMap().Name != "Proving Grounds")) && ((UnitHeal == null) && (Me.HealthPercent < THSettings.Instance.PriorityHeal)))
                {
                    UnitHeal = (WoWUnit) Me;
                }
                if (Me.get_CurrentMap().IsArena && (UnitHeal == null))
                {
                    UnitHeal = (from unit in NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.HealthPercent
                        select unit).FirstOrDefault<WoWUnit>(unit => (((GetDistance(unit) <= 40f) && !DebuffDoNotHeal(unit)) && (unit.HealthPercent < THSettings.Instance.PriorityHeal)) && InLineOfSpellSightCheck(unit));
                }
                if (Me.get_CurrentMap().IsArena && (UnitHeal == null))
                {
                    UnitHeal = (from unit in NearbyFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.HealthPercent
                        select unit).FirstOrDefault<WoWUnit>(unit => (((unit.IsPlayer || unit.IsBeast) || (unit.IsDemon || unit.IsUndead)) && (((unit.MaxHealth > (MeMaxHealth / 3.0)) && (GetDistance(unit) <= 40f)) && !DebuffDoNotHeal(unit))) && InLineOfSpellSightCheck(unit));
                }
                if (UnitHeal == null)
                {
                    UnitHeal = (from unit in NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.HealthPercent
                        select unit).FirstOrDefault<WoWUnit>(unit => ((GetDistance(unit) <= 40f) && !DebuffDoNotHeal(unit)) && InLineOfSpellSightCheck(unit));
                }
                if (UnitHeal == null)
                {
                    UnitHealIsValid = false;
                }
                else
                {
                    UnitHealIsValid = true;
                    HealWeightUnitHeal = HealWeight(UnitHeal);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static bool GetUnitHolyPrismEnemyHeal()
        {
            UnitHolyPrismEnemyHeal = null;
            UnitHolyPrismEnemyHeal = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountUnitHolyPrism)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if (((!FacingOverride(unit) || InvulnerableSpell(unit)) || (CountUnitHolyPrism(unit) < THSettings.Instance.HolyPrismEnemyHealNumber)) || (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return Attackable(unit, 40);
            });
            return BasicCheck(UnitHolyPrismEnemyHeal);
        }

        private static bool GetUnitHolyPrismFriendDPS()
        {
            UnitHolyPrismFriendDPS = null;
            UnitHolyPrismFriendDPS = NearbyFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountUnitHolyPrismFriendDPS)).ThenByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (CountUnitHolyPrismFriendDPS(unit) >= THSettings.Instance.HolyPrismFriendDPSNumber) && Healable(unit, 40));
            return BasicCheck(UnitHolyPrismFriendDPS);
        }

        private static bool GetUnitHolyPrismHoly()
        {
            UnitHolyPrismHoly = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                UnitHolyPrismHoly = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.HealthPercent
                    select unit).FirstOrDefault<WoWUnit>(unit => (((unit.HealthPercent <= THSettings.Instance.HolyPrismEnemyHP) && FacingOverride(unit)) && !InvulnerableSpell(unit)) && Attackable(unit, 40));
            }
            else
            {
                UnitHolyPrismHoly = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.HealthPercent descending
                    select unit).FirstOrDefault<WoWUnit>(unit => (((unit.HealthPercent <= THSettings.Instance.HolyPrismEnemyHP) && FacingOverride(unit)) && !InvulnerableSpell(unit)) && Attackable(unit, 40));
            }
            return BasicCheck(UnitHolyPrismHoly);
        }

        private static bool GetUnitJudgment()
        {
            UnitJudgment = null;
            if (THSettings.Instance.JudgmentBurdenofGuilt && SpellManager.HasSpell("Burden of Guilt"))
            {
                UnitJudgment = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.CountDebuffRootandSnareMechanic)).FirstOrDefault<WoWUnit>(unit => ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && !InvulnerableSpell(unit)) && Attackable(unit, 30 + _bonusJudgementRange));
            }
            if ((THSettings.Instance.JudgmentLongArmoftheLaw && (UnitJudgment == null)) && SpellManager.HasSpell("Long Arm of the Law"))
            {
                UnitJudgment = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && (IsMoving((WoWUnit) Me) && (MeHasAura("Hand of Freedom") || (Me.get_MovementInfo().RunSpeed < 4f)))) && !InvulnerableSpell(unit)) && Attackable(unit, 30 + _bonusJudgementRange));
            }
            if ((THSettings.Instance.SelflessHealer && (UnitJudgment == null)) && (SpellManager.HasSpell("Selfless Healer") && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) < 3.0)))
            {
                UnitJudgment = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (((Me.get_CurrentMap().Name == "Proving Grounds") || ((unit.Combat && unit.GotTarget) && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) && !InvulnerableSpell(unit)) && Attackable(unit, 30 + _bonusJudgementRange));
            }
            return BasicCheck(UnitJudgment);
        }

        private static bool GetUnitJudgmentSelflessHealerHoly()
        {
            UnitJudgmentSelflessHealerHoly = null;
            UnitJudgmentSelflessHealerHoly = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (((Me.get_CurrentMap().Name == "Proving Grounds") || ((unit.Combat && unit.GotTarget) && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) && !InvulnerableSpell(unit)) && Attackable(unit, 30 + _bonusJudgementRange));
            return BasicCheck(UnitJudgmentSelflessHealerHoly);
        }

        private static bool GetUnitRebuke()
        {
            UnitRebuke = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitRebuke = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (FacingOverride(unit) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false))) && Attackable(unit, 5));
            }
            else
            {
                UnitRebuke = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (((unit.Combat && FacingOverride(unit)) && ((Me.get_CurrentMap().Name == "Proving Grounds") || FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) && InterruptCheck(unit, (double) THSettings.Instance.RebukeMs, false))) && Attackable(unit, 5));
            }
            return BasicCheck(UnitRebuke);
        }

        private static bool GetUnitReckoning()
        {
            UnitReckoning = null;
            UnitReckoning = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, bool>(new Func<WoWUnit, bool>(Classname.DebuffDot)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((((UseSpecialization != 1) && !unit.IsPlayer) || unit.Name.Contains("Mine Cart")) || ((((!unit.IsPet || !unit.GotTarget) || (unit.get_CurrentTarget() == Me)) && (!unit.IsPlayer || (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Rogue))))) && ((!unit.IsPlayer || (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Druid)))) || (TalentSort(unit) != 1))))
                {
                    return false;
                }
                return Attackable(unit, 30);
            });
            return BasicCheck(UnitReckoning);
        }

        private static bool GetUnitReckoningProtection()
        {
            UnitReckoningProtection = null;
            UnitReckoningProtection = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((Me.Combat && ((Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid) || (Me.get_CurrentMap().Name == "Proving Grounds"))) && (((unit.Combat && !unit.Fleeing) && (!unit.IsTargetingMeOrPet && FarFriendlyUnits.Contains(unit.get_CurrentTarget()))) && (!UnitHasAura("Vengeance", unit.get_CurrentTarget()) && (unit.GetThreatInfoFor(unit.get_CurrentTarget()).ThreatValue >= 90)))) && Attackable(unit, 30));
            return BasicCheck(UnitReckoningProtection);
        }

        private static bool GetUnitRepentance()
        {
            UnitRepentance = null;
            UnitRepentance = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, byte>(new Func<WoWUnit, byte>(Classname.TalentSortSimple)).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if (((((unit.HealthPercent <= 50.0) || UnitHasAura("Berserker Rage", unit)) || (UnitHasAura("Bear Form", unit) || UnitHasAura("Cat Form", unit))) || ((UnitHasAura("Aquatic Form", unit) || UnitHasAura("Travel Form", unit)) || (UnitHasAura("Ghost Wolf", unit) || UnitHasAura("Lichborne", unit)))) || ((DebuffDot(unit) || InvulnerableSpell(unit)) || (IsTargetedByOurUnit(unit) && (!unit.Mounted || !IsMoving(unit)))))
                {
                    return false;
                }
                return Attackable(unit, 30);
            });
            return BasicCheck(UnitRepentance);
        }

        private static Composite GetUnits()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                EnemyListCacheClear();
                FriendListCacheClear();
                NearbyFriendlyPlayers.Clear();
                NearbyFriendlyUnits.Clear();
                FarFriendlyPlayers.Clear();
                FarFriendlyUnits.Clear();
                NearbyUnFriendlyPlayers.Clear();
                NearbyUnFriendlyUnits.Clear();
                FarUnFriendlyPlayers.Clear();
                FarUnFriendlyUnits.Clear();
                foreach (WoWUnit unit in from unit in GetAllUnits()
                    where ((unit.CanSelect && unit.IsAlive) && (GetDistance(unit) < 60f)) && !Blacklist.Contains(unit.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))
                    select unit)
                {
                    if (IsMyPartyRaidMember(unit))
                    {
                        WoWPlayer player = unit as WoWPlayer;
                        if ((player != null) || NeedHealUnit(unit))
                        {
                            FarFriendlyPlayers.Add(unit);
                            FarFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyFriendlyUnits.Add(unit);
                                NearbyFriendlyPlayers.Add(unit);
                            }
                        }
                        else
                        {
                            FarFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyFriendlyUnits.Add(unit);
                            }
                        }
                        continue;
                    }
                    if (IsEnemy(unit))
                    {
                        WoWPlayer player2 = unit as WoWPlayer;
                        if (player2 != null)
                        {
                            FarUnFriendlyPlayers.Add(unit);
                            FarUnFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyUnFriendlyUnits.Add(unit);
                                NearbyUnFriendlyPlayers.Add(unit);
                            }
                            continue;
                        }
                        FarUnFriendlyUnits.Add(unit);
                        if (unit.Distance <= 40.0)
                        {
                            NearbyUnFriendlyUnits.Add(unit);
                        }
                    }
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static bool GetUnitSacredShieldProt()
        {
            UnitSacredShieldProt = null;
            UnitSacredShieldProt = (from unit in NearbyFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby CountEnemyTargettingUnit(unit, 40f)
                select unit).FirstOrDefault<WoWUnit>(unit => ((unit.Combat && UnitHasAura("Vengeance", unit)) && (!MyAura("Sacred Shield", unit) && (CountEnemyTargettingUnit(unit, 40f) > 0.0))) && Healable(unit, 40));
            return BasicCheck(UnitSacredShieldProt);
        }

        private static bool GetUnitTankEternalFlame()
        {
            UnitTankEternalFlame = null;
            UnitTankEternalFlame = NearbyFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (((unit.Combat & UnitHasAura("Vengeance", unit)) && IsEnemy(unit.get_CurrentTarget())) && ((unit.get_CurrentTarget().get_CurrentTarget() == unit) && (MyAuraTimeLeft("Eternal Flame", unit) <= 1500.0))) && Healable(unit, 40));
            return BasicCheck(UnitTankEternalFlame);
        }

        private static bool GetUnitToBeaconOffTarget(WoWUnit target)
        {
            UnitToBeaconOffTarget = null;
            UnitToBeaconOffTarget = FarFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => ((unit != target) && (HealWeight(unit) < 90.0)) && InLineOfSpellSightCheck(unit));
            return BasicCheck(UnitToBeaconOffTarget);
        }

        private static bool GetUnitToSacredShield()
        {
            UnitToSacredShield = null;
            if (Me.get_CurrentMap().IsRaid || Me.get_CurrentMap().IsDungeon)
            {
                UnitToSacredShield = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => (UnitHasAura("Vengeance", unit) && IsEnemy(unit.get_CurrentTarget())) && Healable(unit, 40));
            }
            if ((UnitToSacredShield == null) && (UseSpecialization != 1))
            {
                GetUnitHasSacredShield();
            }
            if (UnitHealIsValid && (!BasicCheck(UnitHasSacredShield) || (BasicCheck(UnitHasSacredShield) && (HealWeight(UnitHasSacredShield) > HealWeightUnitHeal))))
            {
                UnitToSacredShield = UnitHeal;
            }
            if ((UnitToSacredShield == null) && UnitHealIsValid)
            {
                UnitToSacredShield = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => ((Me.get_CurrentMap().IsBattleground && ((UnitHasAura("Alliance Flag", unit) || UnitHasAura("Horde Flag", unit)) || (UnitHasAura("Netherstorm Flag", unit) || UnitHasAura("Orb of Power", unit)))) && (HealWeight(unit) < (HealWeightUnitHeal + 10.0))) && Healable(unit, 40));
            }
            if (UnitToSacredShield == null)
            {
                UnitToSacredShield = NearbyFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderByDescending<WoWUnit, double>(new Func<WoWUnit, double>(Classname.HealWeight)).FirstOrDefault<WoWUnit>(unit => !MyAura("Sacred Shield", unit) && (HealWeight(UnitHasSacredShield) < HealWeight(unit)));
            }
            return BasicCheck(UnitToSacredShield);
        }

        private static bool GetUnitTurnEvil()
        {
            UnitTurnEvil = null;
            if (SpellManager.HasSpell("Evil is a Point of View"))
            {
                UnitTurnEvilASAP = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, int>(new Func<WoWUnit, int>(Classname.CountFriendTarget)).FirstOrDefault<WoWUnit>(unit => (((unit.get_Class() != ((WoWClass) ((uint) WoWClass.Warrior))) && !InvulnerableSpell(unit)) && !DebuffCC(unit)) && Attackable(unit, 20));
            }
            else
            {
                UnitTurnEvil = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((unit.IsDemon || unit.IsUndead) && !DebuffCC(unit)) && Attackable(unit, 20));
            }
            return BasicCheck(UnitTurnEvil);
        }

        private static bool GetUnitTurnEvilASAP()
        {
            UnitTurnEvilASAP = null;
            if (SpellManager.HasSpell("Evil is a Point of View"))
            {
                UnitTurnEvilASAP = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).OrderBy<WoWUnit, int>(new Func<WoWUnit, int>(Classname.CountFriendTarget)).FirstOrDefault<WoWUnit>(unit => (((unit.get_Class() != ((WoWClass) ((uint) WoWClass.Warrior))) && !InvulnerableSpell(unit)) && !DebuffCC(unit)) && Attackable(unit, 20));
            }
            else
            {
                UnitTurnEvilASAP = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((((unit.Entry == 0xe736) || UnitHasAura("Lichborne", unit)) || (UnitHasAura("Dark Transformation", unit) || (unit.Entry == 0x6cb5))) || ((unit.IsPet && unit.IsDemon) && (unit.IsCasting || unit.IsChanneling))) && (!InvulnerableSpell(unit) && !DebuffCC(unit))) && Attackable(unit, 20));
            }
            return BasicCheck(UnitTurnEvilASAP);
        }

        private static bool GetUnitWarStomp()
        {
            UnitWarStomp = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitWarStomp = NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && InterruptCheck(unit, (double) (THSettings.Instance.RebukeMs + 0x3e8), true)) && Attackable(unit, 8));
            }
            else
            {
                UnitWarStomp = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit()))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || FarFriendlyUnits.Contains(unit.get_CurrentTarget())) && InterruptCheck(unit, (double) (THSettings.Instance.RebukeMs + 0x3e8), true))) && Attackable(unit, 8));
            }
            return BasicCheck(UnitWarStomp);
        }

        private static void GlobalCheck()
        {
            if (GlobalCheckTime <= DateTime.Now)
            {
                GlobalCheckTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
                UpdateMyLatency();
                UpdateEventHandler();
                if (Me.get_CurrentMap().IsRaid)
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(500.0);
                }
                else if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(50.0);
                }
                else
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(100.0);
                }
            }
        }

        private static Composite GuardianofAncientKingsHoly()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.GuardianofAncientKingsHoly || (LastBurstCalled >= DateTime.Now)) || (!UnitHealIsValid || (HealWeightUnitHeal > THSettings.Instance.GuardianofAncientKingsHolyHP))) || ((!UnitHeal.Combat || UnitHeal.IsPet) || (MeHasAura("Divine Shield") || !CanCastCheck("Guardian of Ancient Kings"))))
                {
                    return false;
                }
                if (THSettings.Instance.GuardianofAncientKingsHolyNumber > 1)
                {
                    return CountUnitHealthBelow(THSettings.Instance.GuardianofAncientKingsHolyHP) >= THSettings.Instance.GuardianofAncientKingsHolyNumber;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsCasting && !IsHealing())
                {
                    SpellManager.StopCasting();
                }
                LastBurstCalled = DateTime.Now + TimeSpan.FromSeconds((double) THSettings.Instance.BurstDelay);
                CastSpell("Guardian of Ancient Kings", (WoWUnit) Me, "GuardianofAncientKingsHoly");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite GuardianofAncientKingsProt()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.GuardianofAncientKingsProt && CurrentTargetAttackable(15.0, false, false)) && (!Me.get_CurrentTarget().IsFlying && (Me.HealthPercent < THSettings.Instance.GuardianofAncientKingsProtHP))) && CanCastCheck("Guardian of Ancient Kings"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Guardian of Ancient Kings", (WoWUnit) Me, "GuardianofAncientKingsProt");
            }));
        }

        private static Composite GuardianofAncientKingsRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.GuardianofAncientKings && THSettings.Instance.Burst) && (CurrentTargetAttackable(15.0, false, false) && !CurrentTargetCheckInvulnerablePhysic)) && !Me.get_CurrentTarget().IsFlying) && CanCastCheck("Guardian of Ancient Kings"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Guardian of Ancient Kings", (WoWUnit) Me, "GuardianofAncientKingsRet");
            }));
        }

        private static Composite HammerofJusticeEnemyLow()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.HammerofJusticeEnemyLow && CanCastCheck("Hammer of Justice")) && GetUnitHammerofJusticeEnemyLow(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Hammer of Justice", UnitHammerofJusticeEnemyLow, "HammerofJusticeEnemyLow");
            }));
        }

        private static Composite HammerofJusticeEnemyUsingCD()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.HammerofJusticeEnemyUsingCD && CanCastCheck("Hammer of Justice")) && GetUnitHammerofJusticeEnemyUsingCD(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Hammer of Justice", UnitHammerofJusticeEnemyUsingCD, "HammerofJusticeEnemyUsingCD");
            }));
        }

        private void HammerofJusticeVoid()
        {
            if ((THSettings.Instance.HammerofJusticeInterrupt && (LastInterrupt < DateTime.Now)) && (CanCastCheck("Hammer of Justice") && GetUnitHammerofJusticeInterrupt()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitHammerofJusticeInterrupt.IsCasting && (UnitHammerofJusticeInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitHammerofJusticeInterrupt.IsChanneling)
                {
                    CastSpell("Hammer of Justice", UnitHammerofJusticeInterrupt, "HammerofJusticeInterrupt");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite HammeroftheRighteousProt()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((THSettings.Instance.HammeroftheRighteousProt && !MeHasAura("Hand of Protection")) && (!THSettings.Instance.ShieldofRighterous || (PlayerHolyPower < Me.MaxHolyPower))) && ((CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Hammer of the Righteous")))
                {
                    if (UnitHasAura("Weakened Blows", Me.get_CurrentTarget()))
                    {
                        return CountEnemyNear((WoWUnit) Me, 10f) >= THSettings.Instance.HammeroftheRighteousProtUnit;
                    }
                    return true;
                }
                return false;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Hammer of the Righteous", Me.get_CurrentTarget(), "HammeroftheRighteousProt");
            }));
        }

        private static Composite HammeroftheRighteousRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HammeroftheRighteousRet && !MeHasAura("Hand of Protection")) && (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)) && (((PlayerHolyPower < Me.MaxHolyPower) && CurrentTargetAttackable(5.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) & CanCastCheck("Hammer of the Righteous")))) && (CountEnemyNear((WoWUnit) Me, 8f) >= THSettings.Instance.HammeroftheRighteousRetNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Hammer of the Righteous", Me.get_CurrentTarget(), "HammeroftheRighteousRet");
            }));
        }

        private static Composite HammerofWrathCurrentTarget()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HammerofWrathHoly || (UseSpecialization != 1)) && (((!MeHasAura("Hand of Protection") && CurrentTargetAttackable(30.0, false, false)) && FacingOverride(Me.get_CurrentTarget())) && ((Me.get_CurrentTarget().HealthPercent <= 20.0) || ((UseSpecialization != 1) && MeHasAura("Avenging Wrath"))))) && CanCastCheck("Hammer of Wrath"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Hammer of Wrath", Me.get_CurrentTarget(), "HammerofWrathCurrentTarget");
            }));
        }

        private static Composite HammerofWrathofTarget()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HammerofWrathHoly || (UseSpecialization != 1)) && (!MeHasAura("Hand of Protection") && CanCastCheck("Hammer of Wrath"))) && GetUnitHammerofWrath(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitHammerofWrath);
                CastSpell("Hammer of Wrath", UnitHammerofWrath, "HammerofWrathofTarget");
            }));
        }

        private static Composite HandofFreedomFriend()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HandofFreedomMelee || THSettings.Instance.HandofFreedomHealer) || THSettings.Instance.HandofFreedomCaster) && ((LastHand < DateTime.Now) && CanCastCheck("Hand of Freedom"))) && GetUnitHandofFreedom(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Freedom", UnitHandofFreedom, "");
            }));
        }

        private static Composite HandofFreedomMyself()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HandofFreedomMyself && (LastHand < DateTime.Now)) && (CurrentTargetAttackable(60.0, false, false) && (GetDistance(Me.get_CurrentTarget()) > 5f))) && (DebuffRootorSnare((WoWUnit) Me) && !GetMyHandonUnit((WoWUnit) Me))) && CanCastCheck("Hand of Freedom"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Freedom", (WoWUnit) Me, "HandofFreedomMyself");
            }));
        }

        private static Composite HandofFreedomMyselfHoly()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HandofFreedomMyself && (LastHand < DateTime.Now)) && (IsMoving((WoWUnit) Me) || IsOverrideModeOn)) && (DebuffRootorSnare((WoWUnit) Me) && !GetMyHandonUnit((WoWUnit) Me))) && CanCastCheck("Hand of Freedom"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Freedom", (WoWUnit) Me, "HandofFreedomMyselfHoly");
            }));
        }

        private static Composite HandofProtectionFriend()
        {
            return (Composite) new Decorator(ret => ((((((THSettings.Instance.HandofProtection && (LastHand < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal < THSettings.Instance.HandofProtectionHP))) && (((UnitHeal.Distance < 30.0) && UnitHeal.Combat) && ((HealWeightUnitHeal > 5.0) && !Invulnerable(UnitHeal)))) && (((!UnitHasAura("Forbearance", UnitHeal) && !UnitHasAura("Alliance Flag", UnitHeal)) && (!UnitHasAura("Horde Flag", UnitHeal) && !UnitHasAura("Netherstorm Flag", UnitHeal))) && (!UnitHasAura("Orb of Power", UnitHeal) && ((!IsTank(UnitHeal) || Me.get_CurrentMap().IsBattleground) || Me.get_CurrentMap().IsArena)))) && ((UnitHeal != Me) || ((UnitHeal == Me) && (SpellManager.get_Spells().get_Item("Divine Shield").CooldownTimeLeft.TotalSeconds > 10.0)))) && CanCastCheck("Hand of Protection")) && (CountPhysicDPSTarget(UnitHeal) > 0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Protection", UnitHeal, "HandofProtectionFriend");
            }));
        }

        private static Composite HandofProtectionFriendRemoveCC()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HandofProtectionHPRemoveCC && (LastHand < DateTime.Now)) && CanCastCheck("Hand of Protection")) && GetPlayerHandofProtectionFriendRemoveCC(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Protection", PlayerHandofProtectionFriendRemoveCC, "");
                PlayerHandofProtectionFriendRemoveCC = null;
            }));
        }

        private static Composite HandofProtectionMe()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.HandofProtection && (LastHand < DateTime.Now)) && (Me.Combat && !MeHasAura("Forbearance"))) && ((!MeHasAura("Alliance Flag") && !MeHasAura("Horde Flag")) && (!MeHasAura("Netherstorm Flag") && !MeHasAura("Orb of Power")))) && ((!MeHasAura("Ardent Defender") && (Me.HealthPercent < THSettings.Instance.HandofProtectionHP)) && (CanCastCheck("Hand of Protection") && (SpellManager.get_Spells().get_Item("Divine Shield").CooldownTimeLeft.TotalSeconds > 10.0)))) && (CountPhysicDPSTarget((WoWUnit) Me) > 0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Protection", (WoWUnit) Me, "HandofProtectionMe");
            }));
        }

        private static Composite HandofPurity()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.HandofPurity && (LastHand < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal < THSettings.Instance.HandofPurityHP))) && (((HealWeightUnitHeal > 5.0) && (UnitHeal.Distance < 40.0)) && (UnitHeal.Combat && !GetMyHandonUnit(UnitHeal)))) && !Invulnerable(UnitHeal)) && CanCastCheck("Hand of Purity"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Purity", UnitHeal, "HandofPurity");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.HandofPurityDebuff && (LastHand < DateTime.Now)) && CanCastCheck("Hand of Purity")) && GetPlayerHandofPurityDebuff(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Purity", PlayerHandofPurityDebuff, "HandofPurityDebuff");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite HandofSacrificeFriend()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.HandofSacrifice && (LastHand < DateTime.Now)) && ((Me.HealthPercent > THSettings.Instance.PriorityHeal) && UnitHealIsValid)) && (((HealWeightUnitHeal <= THSettings.Instance.HandofSacrificeHP) && (HealWeightUnitHeal > 5.0)) && (UnitHeal.Combat && !Invulnerable(UnitHeal)))) && (!GetMyHandonUnit(UnitHeal) && CanCastCheck("Hand of Sacrifice"))) && (CountDPSTarget(UnitHeal) > 0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Sacrifice", UnitHeal, "");
            }));
        }

        private static Composite HandofSacrificeFriendRetRemoveCC()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HandofSacCCRemoveMelee || THSettings.Instance.HandofSacCCRemoveCaster) || THSettings.Instance.HandofSacCCRemoveHealer) && ((LastHand < DateTime.Now) && CanCastCheck("Hand of Sacrifice"))) && GetPlayerFriendlyHandofSacASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Sacrifice", PlayerFriendlyHandofSacASAP, "");
            }));
        }

        private static Composite HandofSalvation()
        {
            return (Composite) new Decorator(ret => ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && (((LastHand < DateTime.Now) && !GetMyHandonUnit((WoWUnit) Me)) && (MeHasAura("Divine Plea") && CanCastCheck("Hand of Salvation")))) && GetUnitDispellerAround(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Salvation", (WoWUnit) Me, "");
            }));
        }

        private static Composite HandofSalvHighThreat()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HandofSalvHighThreat && (Me.get_CurrentMap().IsRaid || Me.get_CurrentMap().IsDungeon)) && (((LastHand < DateTime.Now) && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && CanCastCheck("Hand of Salvation")))) && GetUnitHandofSalvHighThreat(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastHand = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                CastSpell("Hand of Salvation", UnitHandofSalvHighThreat, "HandofSalvHighThreat");
            }));
        }

        private static bool HasEnemyMeleeTarget(WoWUnit target, int distance)
        {
            return FarUnFriendlyPlayers.Any<WoWUnit>(unit => ((((BasicCheck(unit) && unit.GotTarget) && ((unit.get_CurrentTarget() == target) && (TalentSort(unit) < 2))) && (GetDistance(unit, target) <= distance)) && !DebuffCC(unit)));
        }

        private static bool HasEnemyNear(WoWUnit unitCenter, float distance)
        {
            return FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Any<WoWUnit>(delegate (WoWUnit unit) {
                if ((!(Me.get_CurrentMap().Name == "Proving Grounds") && !IsDummy(unit)) && ((!unit.Combat || (unit.MaxHealth <= (MeMaxHealth * 0.2))) || (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return (GetDistance(unitCenter, unit) <= distance);
            });
        }

        private static bool HasEnemyPlayerNear(WoWUnit unitCenter, float distance)
        {
            return FarUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Any<WoWUnit>(delegate (WoWUnit unit) {
                if ((!(Me.get_CurrentMap().Name == "Proving Grounds") && !IsDummy(unit)) && ((!unit.Combat || (unit.MaxHealth <= (MeMaxHealth * 0.2))) || (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return (GetDistance(unitCenter, unit) <= distance);
            });
        }

        private static bool Healable(WoWUnit target, int distance = 40)
        {
            return (((BasicCheck(target) && (GetDistance(target) <= distance)) && (!IsEnemy(target) && !DebuffDoNotHeal(target))) && InLineOfSpellSightCheck(target));
        }

        private static double HealWeight(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (!BasicCheck(target))
            {
                return 1000.0;
            }
            if (!target.Combat)
            {
                return target.HealthPercent;
            }
            int num = 0;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => (BasicCheck(unit) && unit.Combat) && (unit.get_CurrentTarget() == target);
                }
                foreach (WoWUnit unit in FarUnFriendlyPlayers.Where<WoWUnit>(predicate))
                {
                    if ((TalentSort(unit) < 4) && BuffBurst(unit))
                    {
                        num += 5;
                    }
                    else
                    {
                        num += 3;
                    }
                }
            }
            else
            {
                if (func2 == null)
                {
                    func2 = unit => (BasicCheck(unit) && unit.Combat) && (unit.get_CurrentTarget() == target);
                }
                foreach (WoWUnit unit2 in FarUnFriendlyUnits.Where<WoWUnit>(func2))
                {
                    if (unit2.IsBoss)
                    {
                        num += 5;
                    }
                    else
                    {
                        num++;
                    }
                }
            }
            return ((target.HealthPercent - num) - THSettings.Instance.HealBalancing);
        }

        private static Composite Hold()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((Me.IsValid && StyxWoW.IsInWorld) && Me.IsAlive) && (!MeHasAura("Food") || (Me.HealthPercent >= THSettings.Instance.DoNotHealAbove))) && (!MeHasAura("Drink") || ((Me.ManaPercent >= THSettings.Instance.DoNotHealAbove) && (Me.GetAuraByName("Drink").TimeLeft.TotalSeconds <= 9.0))))
                {
                    return MeHasAura("Resurrection Sickness");
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsAutoAttacking)
                {
                    Lua.DoString("RunMacroText('/stopattack');", "WoW.lua");
                }
                Styx.Common.Logging.Write("Hold");
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static Composite HolyAvenger()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.HolyAvengerHoly || (LastBurstCalled >= DateTime.Now)) || (!UnitHealIsValid || (HealWeightUnitHeal > THSettings.Instance.HolyAvengerHolyHP))) || ((!UnitHeal.Combat || UnitHeal.IsPet) || (MeHasAura("Divine Shield") || !CanCastCheck("Holy Avenger"))))
                {
                    return false;
                }
                if (THSettings.Instance.HolyAvengerHolyNumber > 1)
                {
                    return CountUnitHealthBelow(THSettings.Instance.HolyAvengerHolyHP) >= THSettings.Instance.HolyAvengerHolyNumber;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsCasting && !IsHealing())
                {
                    SpellManager.StopCasting();
                }
                LastBurstCalled = DateTime.Now + TimeSpan.FromSeconds((double) THSettings.Instance.BurstDelay);
                CastSpell("Holy Avenger", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite HolyAvengerBurstRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Burst && CurrentTargetAttackable(15.0, false, false)) && (!Me.get_CurrentTarget().IsFlying && CanCastCheck("Holy Avenger"))) && (GetSpellCooldown("Guardian of Ancient Kings").TotalSeconds < 294.0)) && (GetSpellCooldown("Guardian of Ancient Kings").TotalSeconds > 0.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Holy Avenger", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite HolyLight()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.HolyLight && UnitHealIsValid) && (HealWeightUnitHeal <= THSettings.Instance.HolyLightHP)) && ((HealWeightUnitHeal > THSettings.Instance.DivineLightHP) || (!UnitHeal.Combat && !Me.Combat))) && (Me.CurrentMana > (WoWSpell.FromId(0x27b).PowerCost * 2))) && CanCastCheck("Holy Light"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconOffTarget(UnitHeal);
                CastSpell("Holy Light", UnitHeal, "");
            }));
        }

        private static Composite HolyPrism()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.HolyPrismFriend && UnitHealIsValid) && ((HealWeightUnitHeal <= THSettings.Instance.HolyPrismFriendHP) && UnitHeal.Combat)) && CanCastCheck("Holy Prism"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Holy Prism", UnitHeal, "HolyPrismFriend");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.HolyPrismEnemyHeal && Me.Combat) && CanCastCheck("Holy Prism")) && GetUnitHolyPrismEnemyHeal(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitHolyPrismEnemyHeal);
                CastSpell("Holy Prism", UnitHolyPrismEnemyHeal, "HolyPrismEnemyHeal");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.HolyPrismFriendDPS && Me.Combat) && CanCastCheck("Holy Prism")) && GetUnitHolyPrismFriendDPS(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Holy Prism", UnitHolyPrismFriendDPS, "HolyPrismFriendDPS");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.HolyPrismEnemy && (UseSpecialization != 1)) && (CurrentTargetAttackable(40.0, false, false) && !Me.get_CurrentTarget().IsPet)) && ((FacingOverride(Me.get_CurrentTarget()) && !CurrentTargetCheckInvulnerableMagic) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.HolyPrismEnemyHP))) && CanCastCheck("Holy Prism"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Holy Prism", Me.get_CurrentTarget(), "HolyPrismEnemy");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.HolyPrismEnemy && (UseSpecialization == 1)) && CanCastCheck("Holy Prism")) && GetUnitHolyPrismHoly(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(UnitHolyPrismHoly);
                CastSpell("Holy Prism", UnitHolyPrismHoly, "UnitHolyPrismHoly");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite HolyRadiance()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HolyRadiance && UnitHealIsValid) && ((HealWeightUnitHeal <= THSettings.Instance.HolyRadianceHP) && !MeHasAura(0x1603e))) && ((PlayerHolyPower < 3.0) && CanCastCheck("Holy Radiance"))) && GetPlayerHolyRadiance(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconAoE();
                CastSpell("Holy Radiance", PlayerHolyRadiance, "HolyRadiance");
            }));
        }

        private static Composite HolyRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                MovementMoveToLoS(ret => Me.get_CurrentTarget()), MovementMoveStop(ret => Me.get_CurrentTarget(), 10.0), DivineShield(), UseHealthStoneHP(), UseBattleStandard(), LayonHands(), DivineProtection(), BeaconSet(), HandofProtectionFriendRemoveCC(), HandofProtectionFriend(), HandofProtectionMe(), DevotionAura(), HandofPurity(), CrowdControlHPSurviveComp(), (Composite) new Decorator(ret => UnitHealIsValid && (UnitHeal.HealthPercent <= THSettings.Instance.UrgentHeal), (Composite) new PrioritySelector(new Composite[] { 
                    HolyAvenger(), AvengingWrath(), DivineFavor(), GuardianofAncientKingsHoly(), DivineLightBubble(), FlashofLightBubble(), HolyPrism(), LightHammer(), ExecutionSentence(), WordofGloryHoly(), LightofDawn(), EternalFlameTank(), EternalFlame(), EternalFlameBlanket(), FlashofLightSelflessHealer(), SacredShieldHoly(), 
                    JudgmentSelflessHealerHoly(), HolyShock(), HolyRadiance(), DivineLightProc(), FlashofLight(), DivineLight(), HandofSalvation(), DivinePlea(), HolyLight()
                 })), (Composite) new Decorator(ret => (UnitHealIsValid && (UnitHeal.HealthPercent > THSettings.Instance.UrgentHeal)) && (UnitHeal.HealthPercent <= THSettings.Instance.PriorityHeal), (Composite) new PrioritySelector(new Composite[] { 
                    ReckoningPvPComp(), HolyAvenger(), AvengingWrath(), DivineFavor(), GuardianofAncientKingsHoly(), DivineLightBubble(), FlashofLightBubble(), HolyPrism(), LightHammer(), ExecutionSentence(), WordofGloryHoly(), LightofDawn(), EternalFlameTank(), EternalFlame(), EternalFlameBlanket(), FlashofLightSelflessHealer(), 
                    SacredShieldHoly(), JudgmentSelflessHealerHoly(), HolyShock(), CleanseFriendlyASAPComp(), AttackASAPRotationInstantComp(), HammerofWrathofTarget(), TurnEvilASAPComp(), HolyRadiance(), DivineLightProc(), FlashofLight(), DivineLight(), HandofSalvation(), DivinePlea(), HolyLight(), HandofFreedomFriend(), HandofFreedomMyselfHoly(), 
                    HandofSacrificeFriend(), CleanseMe()
                 })), 
                (Composite) new Decorator(ret => UnitHealIsValid && (UnitHeal.HealthPercent > THSettings.Instance.PriorityHeal), (Composite) new PrioritySelector(new Composite[] { 
                    ReckoningPvPComp(), CleanseFriendlyASAPComp(), AttackASAPRotationInstantComp(), HammerofWrathCurrentTarget(), HammerofWrathofTarget(), AttackASAPRotationCastComp(), CleanseMe(), TurnEvilASAPComp(), HandofFreedomFriend(), HandofFreedomMyselfHoly(), HandofSacrificeFriend(), TurnEvilComp(), AttackRotationHolyInstantComp(), RepentanceComp(), CrusaderStrikeHoly(), HolyAvenger(), 
                    AvengingWrath(), DivineFavor(), GuardianofAncientKingsHoly(), SpeedofLight(), DivineLightBubble(), FlashofLightBubble(), HolyPrism(), LightHammer(), ExecutionSentence(), WordofGloryHoly(), LightofDawn(), EternalFlameTank(), EternalFlame(), EternalFlameBlanket(), FlashofLightSelflessHealer(), SacredShieldHoly(), 
                    JudgmentSelflessHealerHoly(), HolyShock(), AttackRotationHolyCastComp(), HolyRadiance(), DivineLightProc(), FlashofLight(), DivineLight(), HandofSalvation(), DivinePlea(), HolyLight(), CleanseFriendlyComp(), BuffRotation(), SealofInsight(), RighteousFury()
                 })), AutoRez()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite HolyRotationPvE()
        {
            Composite[] compositeArray = new Composite[] { 
                MovementMoveToLoS(ret => Me.get_CurrentTarget()), MovementMoveStop(ret => Me.get_CurrentTarget(), 10.0), UseHealthStoneHP(), UseBattleStandard(), LayonHands(), DivineProtection(), BeaconSet(), DivineShield(), HandofProtectionFriend(), DevotionAura(), CleanseFriendlyASAPComp(), CleanseFriendlyComp(), HandofSacrificeFriend(), HandofPurity(), HolyAvenger(), AvengingWrath(), 
                DivineFavor(), GuardianofAncientKingsHoly(), HolyPrism(), LightHammer(), ExecutionSentence(), HolyShock(), WordofGloryHoly(), LightofDawn(), EternalFlameTank(), EternalFlame(), EternalFlameBlanket(), FlashofLightSelflessHealer(), JudgmentSelflessHealerHoly(), CrusaderStrikeHoly(), SacredShieldHoly(), DivinePlea(), 
                HolyRadiance(), DivineLightProc(), FlashofLight(), DivineLight(), HolyLight(), BuffRotation(), SealofInsight(), RighteousFury()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite HolyShock()
        {
            return (Composite) new Decorator(ret => ((((Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground) || (((Me.get_CurrentMap().Name == "Proving Grounds") || Me.get_CurrentMap().IsRaid) || Me.Combat)) && ((!MeHasAura("Drink") && !MeHasAura("Food")) && (!MeHasAura("Holy Avenger") || (MeHasAura("Holy Avenger") && (PlayerHolyPower < 3.0))))) && (UnitHealIsValid && ((PlayerHolyPower < 5.0) || (HealWeightUnitHeal <= THSettings.Instance.DoNotHealAbove)))) && CanCastCheck("Holy Shock"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconOffTarget(UnitHeal);
                CastSpell("Holy Shock", UnitHeal, "Holy Shock");
            }));
        }

        private static Composite HolyWrath()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (!THSettings.Instance.HolyWrath || !CanCastCheck("Holy Wrath"))
                {
                    return false;
                }
                return ((CurrentTargetAttackable(10.0, false, false) && FacingOverride(Me.get_CurrentTarget())) && !CurrentTargetCheckInvulnerableMagic) || HasEnemyNear((WoWUnit) Me, 10f);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Holy Wrath", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite Hotkey1()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((THSettings.Instance.Hotkey1Target != 0) && (THSettings.Instance.Hotkey1Key != 0)) && (THSettings.Instance.Hotkey1Spell != 0)) && ((THSettings.Instance.Hotkey1Mod == 0) || ((THSettings.Instance.Hotkey1Mod != 0) && (GetAsyncKeyState(IndexToKeysMod(THSettings.Instance.Hotkey1Mod)) < 0)))) && (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey1Key)) < 0) && HotKeyTargetValidate(THSettings.Instance.Hotkey1Target)) && HotKeySpellValidate(THSettings.Instance.Hotkey1Spell)))
                {
                    SafelyFacingTarget(HotkeyTargettoUnit(THSettings.Instance.Hotkey1Target));
                    if (Me.IsCasting && (Me.get_CastingSpell().Name != HotKeySpelltoName(THSettings.Instance.Hotkey1Spell)))
                    {
                        SpellManager.StopCasting();
                    }
                    CastSpell(HotKeySpelltoName(THSettings.Instance.Hotkey1Spell), HotkeyTargettoUnit(THSettings.Instance.Hotkey1Target), "Hotkey: Cast " + HotKeySpelltoName(THSettings.Instance.Hotkey1Spell) + " on " + HotkeyTargettoUnit(THSettings.Instance.Hotkey1Target).SafeName);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite Hotkey2()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((THSettings.Instance.Hotkey2Target != 0) && (THSettings.Instance.Hotkey2Key != 0)) && (THSettings.Instance.Hotkey2Spell != 0)) && ((THSettings.Instance.Hotkey2Mod == 0) || ((THSettings.Instance.Hotkey2Mod != 0) && (GetAsyncKeyState(IndexToKeysMod(THSettings.Instance.Hotkey2Mod)) < 0)))) && (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey2Key)) < 0) && HotKeyTargetValidate(THSettings.Instance.Hotkey2Target)) && HotKeySpellValidate(THSettings.Instance.Hotkey2Spell)))
                {
                    SafelyFacingTarget(HotkeyTargettoUnit(THSettings.Instance.Hotkey2Target));
                    if (Me.IsCasting && (Me.get_CastingSpell().Name != HotKeySpelltoName(THSettings.Instance.Hotkey2Spell)))
                    {
                        SpellManager.StopCasting();
                    }
                    CastSpell(HotKeySpelltoName(THSettings.Instance.Hotkey2Spell), HotkeyTargettoUnit(THSettings.Instance.Hotkey2Target), "Hotkey: Cast " + HotKeySpelltoName(THSettings.Instance.Hotkey2Spell) + " on " + HotkeyTargettoUnit(THSettings.Instance.Hotkey2Target).SafeName);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite Hotkey3()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((THSettings.Instance.Hotkey3Target != 0) && (THSettings.Instance.Hotkey3Key != 0)) && (THSettings.Instance.Hotkey3Spell != 0)) && ((THSettings.Instance.Hotkey3Mod == 0) || ((THSettings.Instance.Hotkey3Mod != 0) && (GetAsyncKeyState(IndexToKeysMod(THSettings.Instance.Hotkey3Mod)) < 0)))) && (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey3Key)) < 0) && HotKeyTargetValidate(THSettings.Instance.Hotkey3Target)) && HotKeySpellValidate(THSettings.Instance.Hotkey3Spell)))
                {
                    SafelyFacingTarget(HotkeyTargettoUnit(THSettings.Instance.Hotkey3Target));
                    if (Me.IsCasting && (Me.get_CastingSpell().Name != HotKeySpelltoName(THSettings.Instance.Hotkey3Spell)))
                    {
                        SpellManager.StopCasting();
                    }
                    CastSpell(HotKeySpelltoName(THSettings.Instance.Hotkey3Spell), HotkeyTargettoUnit(THSettings.Instance.Hotkey3Target), "Hotkey: Cast " + HotKeySpelltoName(THSettings.Instance.Hotkey3Spell) + " on " + HotkeyTargettoUnit(THSettings.Instance.Hotkey3Target).SafeName);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite Hotkey4()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((THSettings.Instance.Hotkey4Target != 0) && (THSettings.Instance.Hotkey4Key != 0)) && (THSettings.Instance.Hotkey4Spell != 0)) && ((THSettings.Instance.Hotkey4Mod == 0) || ((THSettings.Instance.Hotkey4Mod != 0) && (GetAsyncKeyState(IndexToKeysMod(THSettings.Instance.Hotkey4Mod)) < 0)))) && (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey4Key)) < 0) && HotKeyTargetValidate(THSettings.Instance.Hotkey4Target)) && HotKeySpellValidate(THSettings.Instance.Hotkey4Spell)))
                {
                    SafelyFacingTarget(HotkeyTargettoUnit(THSettings.Instance.Hotkey4Target));
                    if (Me.IsCasting && (Me.get_CastingSpell().Name != HotKeySpelltoName(THSettings.Instance.Hotkey4Spell)))
                    {
                        SpellManager.StopCasting();
                    }
                    CastSpell(HotKeySpelltoName(THSettings.Instance.Hotkey4Spell), HotkeyTargettoUnit(THSettings.Instance.Hotkey4Target), "Hotkey: Cast " + HotKeySpelltoName(THSettings.Instance.Hotkey4Spell) + " on " + HotkeyTargettoUnit(THSettings.Instance.Hotkey4Target).SafeName);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite Hotkey5()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((THSettings.Instance.Hotkey5Target != 0) && (THSettings.Instance.Hotkey5Key != 0)) && (THSettings.Instance.Hotkey5Spell != 0)) && ((THSettings.Instance.Hotkey5Mod == 0) || ((THSettings.Instance.Hotkey5Mod != 0) && (GetAsyncKeyState(IndexToKeysMod(THSettings.Instance.Hotkey5Mod)) < 0)))) && (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey5Key)) < 0) && HotKeyTargetValidate(THSettings.Instance.Hotkey5Target)) && HotKeySpellValidate(THSettings.Instance.Hotkey5Spell)))
                {
                    SafelyFacingTarget(HotkeyTargettoUnit(THSettings.Instance.Hotkey5Target));
                    if (Me.IsCasting && (Me.get_CastingSpell().Name != HotKeySpelltoName(THSettings.Instance.Hotkey5Spell)))
                    {
                        SpellManager.StopCasting();
                    }
                    CastSpell(HotKeySpelltoName(THSettings.Instance.Hotkey5Spell), HotkeyTargettoUnit(THSettings.Instance.Hotkey5Target), "Hotkey: Cast " + HotKeySpelltoName(THSettings.Instance.Hotkey5Spell) + " on " + HotkeyTargettoUnit(THSettings.Instance.Hotkey5Target).SafeName);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static string HotKeySpelltoName(int HotkeySpell)
        {
            switch (HotkeySpell)
            {
                case 1:
                    return "Blinding Light";

                case 2:
                    return "Divine Shield";

                case 3:
                    return "Hammer of Justice";

                case 4:
                    return "Hand of Freedom";

                case 5:
                    return "Hand of Protection";

                case 6:
                    return "Hand of Purity";

                case 7:
                    return "Hand of Sacrifice";

                case 8:
                    return "Hand of Salvation";

                case 9:
                    return "Seal of Insight";

                case 10:
                    return "Seal of Justice";

                case 11:
                    return "Seal of Righteousness";

                case 12:
                    return "Seal of Truth";

                case 13:
                    return "Turn Evil";

                case 14:
                    return "Repentance";
            }
            return "None Exist Spell";
        }

        private static bool HotKeySpellValidate(int HotkeySpell)
        {
            return true;
        }

        private static WoWUnit HotkeyTargettoUnit(int HotkeyTarget)
        {
            switch (HotkeyTarget)
            {
                case 1:
                    if (!BasicCheck(Me.get_CurrentTarget()))
                    {
                        break;
                    }
                    return Me.get_CurrentTarget();

                case 2:
                    if (!BasicCheck(Me.get_FocusedUnit()))
                    {
                        break;
                    }
                    return Me.get_FocusedUnit();

                case 3:
                    return (WoWUnit) Me;
            }
            return null;
        }

        private static bool HotKeyTargetValidate(int HotkeyTarget)
        {
            return (HotkeyTargettoUnit(HotkeyTarget) != null);
        }

        private static bool IGroupHealingOn()
        {
            if (UseSpecialization != 1)
            {
                GroupHealingOn = false;
                return false;
            }
            if (((THSettings.Instance.Group1 && THSettings.Instance.Group2) && (THSettings.Instance.Group3 && THSettings.Instance.Group4)) && ((THSettings.Instance.Group5 && THSettings.Instance.Group6) && (THSettings.Instance.Group7 && THSettings.Instance.Group8)))
            {
                GroupHealingOn = false;
                return false;
            }
            if (((!THSettings.Instance.Group1 && !THSettings.Instance.Group2) && (!THSettings.Instance.Group3 && !THSettings.Instance.Group4)) && ((!THSettings.Instance.Group5 && !THSettings.Instance.Group6) && (!THSettings.Instance.Group7 && !THSettings.Instance.Group8)))
            {
                GroupHealingOn = false;
                return false;
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Selective Group Healing Mode On");
            Styx.Common.Logging.Write("----------------------------------");
            GroupHealingOn = true;
            return true;
        }

        private static Keys IndexToKeys(int index)
        {
            switch (index)
            {
                case 1:
                    return Keys.A;

                case 2:
                    return Keys.B;

                case 3:
                    return Keys.C;

                case 4:
                    return Keys.D;

                case 5:
                    return Keys.E;

                case 6:
                    return Keys.F;

                case 7:
                    return Keys.G;

                case 8:
                    return Keys.H;

                case 9:
                    return Keys.I;

                case 10:
                    return Keys.J;

                case 11:
                    return Keys.K;

                case 12:
                    return Keys.L;

                case 13:
                    return Keys.M;

                case 14:
                    return Keys.N;

                case 15:
                    return Keys.O;

                case 0x10:
                    return Keys.P;

                case 0x11:
                    return Keys.Q;

                case 0x12:
                    return Keys.R;

                case 0x13:
                    return Keys.S;

                case 20:
                    return Keys.T;

                case 0x15:
                    return Keys.U;

                case 0x16:
                    return Keys.V;

                case 0x17:
                    return Keys.W;

                case 0x18:
                    return Keys.X;

                case 0x19:
                    return Keys.Y;

                case 0x1a:
                    return Keys.Z;

                case 0x1b:
                    return Keys.D1;

                case 0x1c:
                    return Keys.D2;

                case 0x1d:
                    return Keys.D3;

                case 30:
                    return Keys.D4;

                case 0x1f:
                    return Keys.D5;

                case 0x20:
                    return Keys.D6;

                case 0x21:
                    return Keys.D7;

                case 0x22:
                    return Keys.D8;

                case 0x23:
                    return Keys.D9;

                case 0x24:
                    return Keys.D0;

                case 0x25:
                    return Keys.Up;

                case 0x26:
                    return Keys.Down;

                case 0x27:
                    return Keys.Left;

                case 40:
                    return Keys.Right;
            }
            return Keys.None;
        }

        internal static Keys IndexToKeysMod(int index)
        {
            switch (index)
            {
                case 1:
                    return Keys.LShiftKey;

                case 2:
                    return Keys.LControlKey;

                case 3:
                    return Keys.Alt;
            }
            return Keys.None;
        }

        public override void Initialize()
        {
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write(string.Concat(new object[] { "Hello level ", Me.Level, " ", Me.get_Race(), " ", Me.get_Class() }));
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write("Thank you for using TuanHA Paladin Special Edition");
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write("For best Combat Routine performance, please set Custom Lag Tolerance to 400 ms.");
            Styx.Common.Logging.Write("Game Menu > Interface > Combat Check Custom Lag Toerance and Adjust the Slider to 400 ms");
            Styx.Common.Logging.Write("Best Non-AFK Botbase are LazyRaider: http://goo.gl/nf0zab or Tyrael http://goo.gl/51E0F6");
            Styx.Common.Logging.Write("For detailed installation guide, visit our new website (Google TuanHA");
            Styx.Common.Logging.Write("");
            Lua.get_Events().AttachEvent("GROUP_ROSTER_UPDATE", new LuaEventHandlerDelegate(Classname.UpdateGroupChangeEvent));
            Lua.get_Events().AttachEvent("ACTIVE_TALENT_GROUP_CHANGED", new LuaEventHandlerDelegate(Classname.UpdateStatusEvent));
            Lua.get_Events().AttachEvent("PLAYER_TALENT_UPDATE", new LuaEventHandlerDelegate(Classname.UpdateMyTalentEvent));
            Lua.get_Events().AttachEvent("GLYPH_ADDED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Lua.get_Events().AttachEvent("GLYPH_UPDATED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Lua.get_Events().AttachEvent("GLYPH_REMOVED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            BotEvents.add_OnBotStarted(new BotEvents.OnBotStartDelegate(Classname.OnBotStartedEvent));
            this.PreBuffSelector();
            this.RotationSelector();
            this.RestSelector();
            this.DeathSelector();
            THSettings.Instance.UpdateStatus = true;
            if (!LoginCheckVal)
            {
                Styx.Common.Logging.Write("Please Log In.");
                this.OnButtonPress();
            }
        }

        private static void InLineOfSpellSightCacheAdd(WoWUnit unit, int expireMilliseconds = 100)
        {
            if (!InLineOfSpellSightCache.ContainsKey(unit.Guid))
            {
                InLineOfSpellSightCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromMilliseconds((double) expireMilliseconds));
            }
        }

        private static void InLineOfSpellSightCacheClear()
        {
            foreach (ulong num in (from unit in InLineOfSpellSightCache
                where unit.Value < DateTime.Now
                select unit.Key).ToList<ulong>())
            {
                InLineOfSpellSightCache.Remove(num);
            }
        }

        private static bool InLineOfSpellSightCheck(WoWUnit target)
        {
            if (!BasicCheck(target))
            {
                return false;
            }
            InLineOfSpellSightCacheClear();
            if ((target != Me) && !InLineOfSpellSightCache.ContainsKey(target.Guid))
            {
                if (!target.InLineOfSpellSight)
                {
                    return false;
                }
                if (Me.get_CurrentMap().IsRaid || Me.get_CurrentMap().IsDungeon)
                {
                    InLineOfSpellSightCacheAdd(target, 300);
                    return true;
                }
                InLineOfSpellSightCacheAdd(target, 100);
            }
            return true;
        }

        private static Composite Inquisition()
        {
            return (Composite) new Decorator(ret => ((CurrentTargetAttackable(40.0, false, false) && ((PlayerHolyPower >= THSettings.Instance.InquisitionHolyPower) || MeHasAura(0x1603e))) && (MyAuraTimeLeft(0x14be3, (WoWUnit) Me) <= 5000.0)) && CanCastCheck("Inquisition"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Inquisition", (WoWUnit) Me, "Inquisition");
            }));
        }

        private static Composite InquisitionMeTopUp()
        {
            return (Composite) new Decorator(ret => (((PlayerHolyPower >= THSettings.Instance.InquisitionHolyPower) || MeHasAura(0x1603e)) && (MyAuraTimeLeft("Inquisition", (WoWUnit) Me) < 1000.0)) && CanCastCheck("Inquisition"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Inquisition", (WoWUnit) Me, "");
            }));
        }

        private static bool InterruptCheck(WoWUnit unit, double millisecondsleft, bool includeUninterruptable = true)
        {
            return ((((((unit != null) && unit.IsValid) && ((Me.get_CurrentMap().Name == "Proving Grounds") || unit.Combat)) && (unit.IsCasting || unit.IsChanneling)) && ((includeUninterruptable || unit.CanInterruptCurrentSpellCast) && (!unit.IsCasting || !DoNotInterrupt.Contains(unit.CastingSpellId)))) && ((!unit.IsChanneling || !DoNotInterrupt.Contains(unit.ChanneledCastingSpellId)) && (!unit.IsCasting || (unit.CurrentCastTimeLeft.TotalMilliseconds <= (millisecondsleft + MyLatency)))));
        }

        private static bool Invulnerable(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableHS.Contains(aura.SpellId));
        }

        private static bool InvulnerablePhysic(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return UnitHasAura(0x3fe, target);
        }

        private static bool InvulnerableRootandSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableRootandSnareHS.Contains(aura.SpellId));
        }

        private static bool InvulnerableSpell(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableSpellHS.Contains(aura.SpellId));
        }

        private static bool InvulnerableStun(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return (((target.get_Class() == ((WoWClass) ((uint) WoWClass.Monk))) && (TalentSort(target) > 3)) || target.GetAllAuras().Any<WoWAura>(aura => InvulnerableStunHS.Contains(aura.SpellId)));
        }

        private static bool IsDummy(WoWUnit target)
        {
            if (!BasicCheck(target))
            {
                return false;
            }
            if (((((target.Entry != 0x79aa) && (target.Entry != 0x10637)) && ((target.Entry != 0xb637) && (target.Entry != 0x7f22))) && (((target.Entry != 0x79a8) && (target.Entry != 0x7f1f)) && ((target.Entry != 0x7f9b) && (target.Entry != 0x7f1e)))) && (target.Entry != 0x7f9a))
            {
                return (target.Entry == 0x773f);
            }
            return true;
        }

        private static bool IsEnemy(WoWUnit target)
        {
            if (EnemyListCache.ContainsKey(target.Guid))
            {
                return true;
            }
            if (!FriendListCache.ContainsKey(target.Guid))
            {
                if (IsMyPartyRaidMember(target))
                {
                    if (UnitHasAura("Reshape Life", target) || UnitHasAura("Convert", target))
                    {
                        return true;
                    }
                    FriendListCacheAdd(target, 60);
                    return false;
                }
                if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
                if ((!target.IsFriendly && target.Attackable) && !target.IsQuestGiver)
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
                if ((Me.Combat && IsDummy(target)) && Me.IsFacing((WoWObject) target))
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
            }
            return false;
        }

        private static bool IsHealing()
        {
            if (!Me.IsCasting)
            {
                return false;
            }
            if ((!(Me.get_CastingSpell().Name == "Flash of Light") && !(Me.get_CastingSpell().Name == "Divine Light")) && !(Me.get_CastingSpell().Name == "Holy Light"))
            {
                return (Me.get_CastingSpell().Name == "Holy Radiance");
            }
            return true;
        }

        private static bool IsMoving(WoWUnit target)
        {
            if ((!target.get_MovementInfo().MovingBackward && !target.get_MovementInfo().MovingForward) && !target.get_MovementInfo().MovingStrafeLeft)
            {
                return target.get_MovementInfo().MovingStrafeRight;
            }
            return true;
        }

        private static bool IsMyPartyRaidMember(WoWUnit target)
        {
            if (FriendListCache.ContainsKey(target.Guid))
            {
                return true;
            }
            if (!EnemyListCache.ContainsKey(target.Guid))
            {
                if (NeedHealUnit(target))
                {
                    FriendListCacheAdd(target, 60);
                    return true;
                }
                if (target.IsPlayer)
                {
                    WoWPlayer player = target as WoWPlayer;
                    if ((player != null) && ((player == Me) || player.IsInMyPartyOrRaid))
                    {
                        FriendListCacheAdd(target, 60);
                        return true;
                    }
                }
                else
                {
                    WoWPlayer player2 = target.get_CreatedByUnit() as WoWPlayer;
                    if ((player2 != null) && ((player2 == Me) || player2.IsInMyPartyOrRaid))
                    {
                        FriendListCacheAdd(target, 60);
                        return true;
                    }
                }
            }
            return false;
        }

        private static bool IsTank(WoWUnit target)
        {
            if (target.Entry != 0x11a1a)
            {
                return UnitHasAura("Vengeance", target);
            }
            return true;
        }

        private static bool IsTargetedByOurUnit(WoWUnit u)
        {
            UnitFriendlyTargeting = null;
            UnitFriendlyTargeting = FarFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => (unit != Me) && (unit.get_CurrentTarget() == u));
            return BasicCheck(UnitFriendlyTargeting);
        }

        private static void ItemsCooldownCacheAdd(WoWItem Item, DateTime CooldownBack)
        {
            ItemsCooldownCache.Add(Item, CooldownBack);
        }

        private static void ItemsCooldownCacheClear()
        {
            foreach (WoWItem item in (from unit in ItemsCooldownCache
                where unit.Value <= DateTime.Now
                select unit.Key).ToList<WoWItem>())
            {
                ItemsCooldownCache.Remove(item);
            }
        }

        private static Composite JudgementProt()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((!HasGlyph.Contains("54922") || Me.get_CurrentMap().IsBattleground) || Me.get_CurrentMap().IsArena) && ((CurrentTargetAttackable((double) (30 + _bonusJudgementRange), false, false) && !CurrentTargetCheckInvulnerableMagic) && ((!THSettings.Instance.ShieldofRighterous || (PlayerHolyPower < Me.MaxHolyPower)) || (GetDistance(Me.get_CurrentTarget()) > 5f)))) && CanCastCheck("Judgment"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", Me.get_CurrentTarget(), "JudgementRet");
            })), (Composite) new Decorator(ret => ((HasGlyph.Contains("54922") && (!THSettings.Instance.ShieldofRighterous || (PlayerHolyPower < Me.MaxHolyPower))) && CanCastCheck("Judgment")) && GetUnitDoubleJeopardy(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", UnitDoubleJeopardy, "JudgementRet: UnitDoubleJeopardy");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite JudgementRangeRetPvE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Judgment && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && ((!MeHasAura("Hand of Protection") && CurrentTargetAttackable((double) (30 + _bonusJudgementRange), false, false)) && (SpellManager.HasSpell("Long Arm of the Law") && (GetDistance(Me.get_CurrentTarget()) > 8f)))) && CanCastCheck("Judgment"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", Me.get_CurrentTarget(), "JudgementRangeRetPvE");
            }));
        }

        private static Composite JudgementRangeRetPvP()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.Judgment || !CurrentTargetAttackable((double) (30 + _bonusJudgementRange), false, false)) || !Me.get_CurrentTarget().IsPlayer) || (((!SpellManager.HasSpell("Long Arm of the Law") || MeHasAura(0x15485)) || (GetDistance(Me.get_CurrentTarget()) <= 5f)) && (!SpellManager.HasSpell("Burden of Guilt") || DebuffRootorSnare(Me.get_CurrentTarget()))))
                {
                    return false;
                }
                return CanCastCheck("Judgment");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", Me.get_CurrentTarget(), "JudgementRangeRetPvP");
            }));
        }

        private static Composite JudgementRet()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((!HasGlyph.Contains("54922") || Me.get_CurrentMap().IsBattleground) || Me.get_CurrentMap().IsArena) && ((CurrentTargetAttackable((double) (30 + _bonusJudgementRange), false, false) && !CurrentTargetCheckInvulnerableMagic) && ((PlayerHolyPower < Me.MaxHolyPower) || (GetDistance(Me.get_CurrentTarget()) > 5f)))) && CanCastCheck("Judgment"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", Me.get_CurrentTarget(), "JudgementRet");
            })), (Composite) new Decorator(ret => ((HasGlyph.Contains("54922") && (PlayerHolyPower < Me.MaxHolyPower)) && CanCastCheck("Judgment")) && GetUnitDoubleJeopardy(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", UnitDoubleJeopardy, "JudgementRet: UnitDoubleJeopardy");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite JudgmentSelflessHealerHoly()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((SpellManager.HasSpell("Selfless Healer") && ((!MeHasAura(0x1be4a) || (MeHasAura(0x1be4a) && (MyAuraStackCount(0x1be4a, (WoWUnit) Me) < 3.0))) || (MeHasAura(0x1be4a) && (MyAuraTimeLeft(0x1be4a, (WoWUnit) Me) < 6000.0)))) && CanCastCheck("Judgment")) && GetUnitJudgmentSelflessHealerHoly(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Judgment", UnitJudgmentSelflessHealerHoly, "JudgmentSelflessHealerHoly");
                UnitJudgmentSelflessHealerHoly = null;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite LayonHands()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.LayonHands && !Me.get_CurrentMap().IsArena) && (!Me.IsFFAPvPFlagged && Me.Combat)) && ((!MeHasAura("Forbearance") && (Me.HealthPercent <= THSettings.Instance.LayonHandsHP)) && CanCastCheck("Lay on Hands"))) && (SpellManager.get_Spells().get_Item("Divine Shield").CooldownTimeLeft.TotalSeconds > 10.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Lay on Hands", (WoWUnit) Me, "LayonHands");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.LayonHands || !Me.Combat) || (Me.get_CurrentMap().IsArena || Me.IsFFAPvPFlagged)) || ((!UnitHealIsValid || (HealWeightUnitHeal > THSettings.Instance.LayonHandsHP)) || UnitHasAura("Forbearance", UnitHeal))) || (((!UnitHasAura("Alliance Flag", UnitHeal) && !UnitHasAura("Horde Flag", UnitHeal)) && (!UnitHasAura("Netherstorm Flag", UnitHeal) && !UnitHasAura("Orb of Power", UnitHeal))) && (((Me.get_CurrentTarget() != UnitHeal) && (Me.get_FocusedUnit() != UnitHeal)) && (!Me.get_CurrentMap().IsRaid && !Me.get_CurrentMap().IsDungeon))))
                {
                    return false;
                }
                return CanCastCheck("Lay on Hands");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Lay on Hands", UnitHeal, "LayonHands");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite LightHammer()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.LightsHammerFriend && Me.Combat) && CanCastCheck("Light's Hammer")) && GetPlayerLightsHammer(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Light's Hammer", PlayerLightsHammer, "LightsHammerFriend");
                LastClickRemoteLocation = DateTime.Now + TimeSpan.FromMilliseconds(300.0);
                while (LastClickRemoteLocation > DateTime.Now)
                {
                    SpellManager.ClickRemoteLocation(PlayerLightsHammer.get_Location());
                }
            })), (Composite) new Decorator(ret => (((THSettings.Instance.LightsHammerEnemy && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && (UseSpecialization != 1))) && CanCastCheck("Light's Hammer")) && (CountEnemyNear(Me.get_CurrentTarget(), 10f) >= THSettings.Instance.LightsHammerEnemyNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Light's Hammer", Me.get_CurrentTarget(), "LightsHammerEnemy Ret/Prot");
                LastClickRemoteLocation = DateTime.Now + TimeSpan.FromMilliseconds(300.0);
                while (LastClickRemoteLocation > DateTime.Now)
                {
                    SpellManager.ClickRemoteLocation(Me.get_CurrentTarget().get_Location());
                }
            })), (Composite) new Decorator(ret => (((THSettings.Instance.LightsHammerEnemy && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && (UseSpecialization == 1))) && CanCastCheck("Light's Hammer")) && GetEnemyLightsHammer(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Light's Hammer", EnemyLightsHammer, "LightsHammerEnemy Holy");
                LastClickRemoteLocation = DateTime.Now + TimeSpan.FromMilliseconds(300.0);
                while (LastClickRemoteLocation > DateTime.Now)
                {
                    SpellManager.ClickRemoteLocation(EnemyLightsHammer.get_Location());
                }
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite LightofDawn()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.LightofDawn && UnitHealIsValid) && (HealWeightUnitHeal <= THSettings.Instance.LightofDawnHP)) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && CanCastCheck("Light of Dawn")) && ((MeHasAura(0x1603e) && (MyAuraTimeLeft(0x1603e, (WoWUnit) Me) < 3000.0)) || (CountUnitLightofDawn() >= THSettings.Instance.LightofDawnNumber)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconAoE();
                CastSpell("Light of Dawn", (WoWUnit) Me, "");
            }));
        }

        private static Composite LoginCheck()
        {
            return (Composite) new Decorator(ret => !LoginCheckVal, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Please Click Class Config to Login.");
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static Composite MainRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                LoginCheck(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F10) != 0))
                    {
                        LastWriteDebug = DateTime.Now + TimeSpan.FromSeconds(5.0);
                        Styx.Common.Logging.Write("=============================");
                        Styx.Common.Logging.Write("SpellsCooldownCache");
                        object[] args = new object[] { (DateTime.Now + SpellManager.GlobalCooldownLeft).ToString("ss:fff"), DateTime.Now.ToString("ss:fff") };
                        Styx.Common.Logging.Write("{1} GCDBack {0}", args);
                        foreach (KeyValuePair<string, DateTime> pair in SpellsCooldownCache)
                        {
                            Styx.Common.Logging.Write("{2}: {0} - {1}", new object[] { pair.Key, pair.Value.ToString("ss:fff"), DateTime.Now.ToString("ss:fff") });
                        }
                        Styx.Common.Logging.Write("=============================");
                    }
                    if (GetAsyncKeyState(Keys.F9) != 0)
                    {
                        Styx.Common.Logging.Write("=============================");
                        object[] objArray3 = new object[1];
                        TimeSpan span = (TimeSpan) (DateTime.Now - LastRotationTime);
                        objArray3[0] = span.TotalMilliseconds;
                        Styx.Common.Logging.Write("LastRotationTime take {0} ms", objArray3);
                        LastRotationTime = DateTime.Now;
                        Styx.Common.Logging.Write("=============================");
                    }
                    if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F8) != 0))
                    {
                        LastWriteDebug = DateTime.Now + TimeSpan.FromSeconds(5.0);
                        int num = 1;
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("NearbyFriendlyPlayers");
                        foreach (WoWUnit unit in NearbyFriendlyPlayers)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("NearbyFriendlyUnits");
                        foreach (WoWUnit unit2 in NearbyFriendlyUnits)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit2.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("FarFriendlyPlayers");
                        foreach (WoWUnit unit3 in FarFriendlyPlayers)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit3.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("FarFriendlyUnits");
                        foreach (WoWUnit unit4 in FarFriendlyUnits)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit4.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("NearbyUnFriendlyPlayers");
                        foreach (WoWUnit unit5 in NearbyUnFriendlyPlayers)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit5.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("NearbyUnFriendlyUnits");
                        foreach (WoWUnit unit6 in NearbyUnFriendlyUnits)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit6.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("FarUnFriendlyPlayers");
                        foreach (WoWUnit unit7 in FarUnFriendlyPlayers)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit7.SafeName);
                            num++;
                        }
                        Styx.Common.Logging.Write("=============================");
                        num = 1;
                        Styx.Common.Logging.Write("FarUnFriendlyUnits");
                        foreach (WoWUnit unit8 in FarUnFriendlyUnits)
                        {
                            Styx.Common.Logging.Write(num + ". " + unit8.SafeName);
                            num++;
                        }
                    }
                    if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F7) != 0))
                    {
                        LastWriteDebug = DateTime.Now + TimeSpan.FromSeconds(5.0);
                        Styx.Common.Logging.Write("=============================");
                        foreach (WoWAura aura in Me.GetAllAuras())
                        {
                            Styx.Common.Logging.Write("{0} {1}", new object[] { aura.Name, aura.SpellId });
                        }
                        Styx.Common.Logging.Write("=============================");
                        if (BasicCheck(Me.get_CurrentTarget()))
                        {
                            Styx.Common.Logging.Write("Me.CurrentTarget.GetAllAuras()");
                            foreach (WoWAura aura2 in Me.get_CurrentTarget().GetAllAuras())
                            {
                                Styx.Common.Logging.Write("{0} {1} {2} {3} {4}", new object[] { aura2.Name, aura2.SpellId, aura2.CreatorGuid, MeGuid, Me.Guid });
                            }
                            Styx.Common.Logging.Write("=============================");
                        }
                    }
                    CurrentTargetCheck();
                    return (RunStatus) RunStatus.Failure;
                }), Hold(), Hotkey1(), Hotkey2(), Hotkey3(), Hotkey4(), Hotkey5(), ManualCastPause(), (Composite) new Decorator(ret => THSettings.Instance.Pause, (Composite) new Styx.TreeSharp.Action(param0 => (RunStatus) RunStatus.Success)), (Composite) new Decorator(ret => THSettings.Instance.UpdateStatus, (Composite) new Styx.TreeSharp.Action(param0 => (RunStatus) RunStatus.Success)), GetUnits(), GetUnitHeal(), GetUnitAttack(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    if (((((!IsOverrideModeOn && (GetAsyncKeyState(Keys.LButton) < 0)) && (GetAsyncKeyState(Keys.RButton) < 0)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleLeft)) < 0) && (IndexToKeys(THSettings.Instance.StrafleLeft) != Keys.None))) || (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Forward)) < 0) && (IndexToKeys(THSettings.Instance.Forward) != Keys.None)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleRight)) < 0) && (IndexToKeys(THSettings.Instance.StrafleRight) != Keys.None)))) || ((((GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnLeft)) < 0) && (IndexToKeys(THSettings.Instance.TurnLeft) != Keys.None)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Backward)) < 0) && (IndexToKeys(THSettings.Instance.Backward) != Keys.None))) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnRight)) < 0) && (IndexToKeys(THSettings.Instance.TurnRight) != Keys.None))))
                    {
                        IsOverrideModeOn = true;
                    }
                    if ((IsOverrideModeOn && ((GetAsyncKeyState(Keys.LButton) >= 0) || (GetAsyncKeyState(Keys.RButton) >= 0))) && ((((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleLeft)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Forward)) >= 0)) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleRight)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnLeft)) >= 0))) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Backward)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnRight)) >= 0))))
                    {
                        IsOverrideModeOn = false;
                    }
                    if ((Me.get_CurrentTarget() != null) && (MyLastTarget != Me.get_CurrentTarget()))
                    {
                        MyLastTarget = Me.get_CurrentTarget();
                    }
                    if (((Me.get_CurrentTarget() != null) && !Me.get_CurrentTarget().IsAlive) && Me.Combat)
                    {
                        Lua.DoString("RunMacroText(\"/cleartarget\")", "WoW.lua");
                    }
                    if (((Me.get_CurrentTarget() != null) && !Me.get_CurrentTarget().IsPlayer) && (Me.get_CurrentTarget().IsFriendly && Me.get_CurrentTarget().IsSafelyBehind((WoWObject) Me)))
                    {
                        Lua.DoString("RunMacroText(\"/cleartarget\")", "WoW.lua");
                    }
                    return (RunStatus) RunStatus.Failure;
                }), SetAutoAttack(), 
                UseRacial(), UseTrinket(), UseProfession(), (Composite) new Decorator(ret => (UseSpecialization == 1) && Me.get_CurrentMap().IsRaid, HolyRotationPvE()), (Composite) new Decorator(ret => ((Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.PaladinHoly))) && !Me.get_CurrentMap().IsRaid) && !Me.Mounted, HolyRotation()), (Composite) new Decorator(ret => (UseSpecialization == 3) && !Me.Mounted, RetributionRotation()), (Composite) new Decorator(ret => (UseSpecialization == 2) && !Me.Mounted, ProtectionRotation()), Dismount()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite ManualCastPause()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => THSettings.Instance.AutoDetectManualCast && AnyKeyPressed(), (Composite) new ActionAlwaysSucceed()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, Colors.Gray, "{0} Manual Cast Detected, Pause for {1} ms", new object[] { DateTime.Now.ToString("ss:fff"), THSettings.Instance.AutoDetectManualCastMS });
            }), (Composite) new WaitContinue(TimeSpan.FromMilliseconds((double) THSettings.Instance.AutoDetectManualCastMS), ret => false, (Composite) new ActionAlwaysSucceed()) };
            return (Composite) new Sequence(compositeArray);
        }

        private static bool MeHasAura(int auraID)
        {
            return Me.GetAllAuras().Any<WoWAura>(aura => (aura.SpellId == auraID));
        }

        private static bool MeHasAura(string auraName)
        {
            return Me.GetAllAuras().Any<WoWAura>(aura => (aura.Name == auraName));
        }

        public Composite MovementMoveBehind(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.AutoMove || (DateTime.Now <= DoNotMove)) || (IsOverrideModeOn || Me.IsCasting)) || (((toUnit == null) || (toUnit(ret) == null)) || ((toUnit(ret) == Me) || !toUnit(ret).IsAlive))) || ((GetDistance(toUnit(ret)) > 5f) || Me.IsBehind(toUnit(ret))))
                {
                    return false;
                }
                return toUnit(ret).IsPlayer || ((!toUnit(ret).IsPlayer && (toUnit(ret).get_CurrentTarget() != Me)) && toUnit(ret).Combat);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location().RayCast(toUnit(ret).Rotation + WoWMathHelper.DegreesToRadians(150f), 3f));
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveStop(UnitSelectionDelegate toUnit, double range)
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AutoMove && !IsOverrideModeOn) && ((toUnit != null) && (toUnit(ret) != null))) && (((toUnit(ret) != Me) && toUnit(ret).IsAlive) && (IsMoving((WoWUnit) Me) && IsEnemy(toUnit(ret))))) && (GetDistance(toUnit(ret)) <= range)) && InLineOfSpellSightCheck(toUnit(ret)), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.get_PlayerMover().MoveStop();
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveToLoS(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.AutoMove || (DateTime.Now <= DoNotMove)) || (IsOverrideModeOn || Me.IsCasting)) || (((toUnit == null) || (toUnit(ret) == null)) || ((toUnit(ret) == Me) || !toUnit(ret).IsAlive))) || !IsEnemy(toUnit(ret)))
                {
                    return false;
                }
                if (GetDistance(toUnit(ret)) <= 30f)
                {
                    return !InLineOfSpellSightCheck(toUnit(ret));
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveToMelee(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AutoMove && (DateTime.Now > DoNotMove)) && (!IsOverrideModeOn && !Me.IsCasting)) && (((toUnit != null) && (toUnit(ret) != null)) && ((toUnit(ret) != Me) && toUnit(ret).IsAlive))) && IsEnemy(toUnit(ret))) && (GetDistance(toUnit(ret)) > 3f), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool MyAura(int auraID, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)));
        }

        private static bool MyAura(string auraName, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)));
        }

        private static double MyAuraStackCount(int auraID, WoWUnit target)
        {
            return (double) (from aura in target.GetAllAuras()
                where (aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)
                select aura.StackCount).FirstOrDefault<uint>();
        }

        private static double MyAuraStackCount(string auraName, WoWUnit target)
        {
            return (double) (from aura in target.GetAllAuras()
                where (aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)
                select aura.StackCount).FirstOrDefault<uint>();
        }

        private static double MyAuraTimeLeft(int auraID, WoWUnit target)
        {
            return (from aura in target.GetAllAuras()
                where (aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)
                select aura.TimeLeft.TotalMilliseconds).FirstOrDefault<double>();
        }

        private static double MyAuraTimeLeft(string auraName, WoWUnit target)
        {
            return (from aura in target.GetAllAuras()
                where (aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)
                select aura.TimeLeft.TotalMilliseconds).FirstOrDefault<double>();
        }

        private static bool NeedHealUnit(WoWUnit target)
        {
            return (NeedHealUnitHS.Contains(target.Entry) && target.IsFriendly);
        }

        private static void OnBotStartedEvent(object o)
        {
            if ((Me.get_Inventory().get_Equipped().get_Hands() != null) && Me.get_Inventory().get_Equipped().get_Hands().Name.Contains("Malevolent Gladiator's Scaled Gauntlets"))
            {
                _bonusJudgementRange = 10;
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Update Status on Bot Start");
            Styx.Common.Logging.Write("----------------------------------");
            THSettings.Instance.Pause = false;
            THSettings.Instance.UpdateStatus = true;
        }

        public override void OnButtonPress()
        {
            if (LoginCheckVal)
            {
                new THForm().ShowDialog();
            }
            else
            {
                new THLogin().ShowDialog();
            }
        }

        private static int OverrideToSpellId(string spellName)
        {
            switch (spellName)
            {
                case "Eternal Flame":
                    return 0x1bdf3;

                case "Turn Evil":
                    return 0x236ab;

                case "Exorcism":
                    return 0x1dcb0;

                case "Fist of Justice":
                    return 0x19c79;
            }
            return 0;
        }

        private Composite PreBuffSelector()
        {
            if (this._preCombatBuffBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing pre-combat buff behaviours.");
                this._preCombatBuffBehavior = (Composite) new PrioritySelector(new Composite[] { MainRotation() });
            }
            return null;
        }

        private static Composite ProtectionRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                AutoTargetProt(), ReckoningCompProtection(), ArdentDefender(), BubbleFlashofLightRet(), CancelBubbleProtection(), MovementMoveToMelee(ret => Me.get_CurrentTarget()), MovementMoveStop(ret => Me.get_CurrentTarget(), 3.0), LayonHands(), AvengingWrathBurstRet(), HolyAvengerBurstRet(), DivineProtection(), DevotionAura(), UseHealthStoneHP(), UseBattleStandard(), GuardianofAncientKingsProt(), DivineShield(), 
                FlashofLightSelflessHealer(), FlashofLightSelflessHealerExpiring(), HandofProtectionMe(), HandofPurity(), SacredShieldMeProt(), SacredShieldTankProt(), HandofProtectionFriendRemoveCC(), HandofProtectionFriend(), CrowdControlHPSurviveComp(), HandofFreedomMyself(), SealProtection(), HolyPrism(), ExecutionSentence(), WordofGloryMeProt(), LightHammer(), HandofSalvHighThreat(), 
                AvengersShieldLoseThreat(), WordofGloryFriendProt(), ShieldoftheRighteous(), JudgementRangeRetPvP(), HammeroftheRighteousProt(), CrusaderStrikeProt(), JudgementProt(), AvengersShieldGrandCrusader(), ConsecrationAoE(), AvengersShieldLowestThreatUnit(), AvengersShield(), HolyWrath(), HammerofWrathCurrentTarget(), HammerofWrathofTarget(), Consecration(), WordofGloryMeTopUpRet(), 
                FlashofLightMeRet(), FlashofLightFriendRet(), FlashofLightMeTopUpRet(), BuffRotation(), RighteousFury(), DivinePlea(), AutoRez()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        public override void Pulse()
        {
            if (BasicCheck((WoWUnit) Me) && StyxWoW.IsInWorld)
            {
                if (THSettings.Instance.UpdateStatus)
                {
                    this.UpdateStatus();
                }
                else
                {
                    GlobalCheck();
                    if (!Me.Mounted)
                    {
                        RebukeVoid();
                        ArcaneTorrentVoid();
                        this.HammerofJusticeVoid();
                        this.AvengersShieldInterruptVoid();
                        this.BlindingLightVoid();
                        this.WarStompVoid();
                        this.StopCastingCheck();
                    }
                    if (((THSettings.Instance.PauseKeyUse && (THSettings.Instance.PauseKey != 0)) && ((GetAsyncKeyState(Keys.LControlKey) < 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.PauseKey)) < 0))) && (LastSwitch.AddSeconds(1.0) < DateTime.Now))
                    {
                        if (THSettings.Instance.Pause)
                        {
                            THSettings.Instance.Pause = false;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Pause Mode is OFF, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.PauseKey) + " to Override bot action.");
                        }
                        else
                        {
                            THSettings.Instance.Pause = true;
                            THSettings.Instance.UpdateStatus = true;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Pause Mode is ON, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.PauseKey) + " to resume bot action.");
                        }
                    }
                    if (THSettings.Instance.Burst && (BurstLast < DateTime.Now))
                    {
                        THSettings.Instance.Burst = false;
                        BurstLast = DateTime.Now;
                        Styx.Common.Logging.Write("Burst Mode is OFF");
                    }
                    if (((THSettings.Instance.BurstKey == 1) && !THSettings.Instance.Burst) && !DebuffCC((WoWUnit) Me))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Cooldown");
                        THSettings.Instance.Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 2) && !THSettings.Instance.Burst) && (CurrentTargetAttackable(30.0, false, false) && Me.get_CurrentTarget().IsBoss)) && !DebuffCC((WoWUnit) Me))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Cooldown (Boss Only)");
                        THSettings.Instance.Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 3) && !THSettings.Instance.Burst) && ((MeHasAura("Bloodlust") || MeHasAura("Heroism")) || (MeHasAura("Time Warp") || MeHasAura("Ancient Hysteria")))) && !DebuffCC((WoWUnit) Me))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Bloodlust/Heroism/Time Warp/Ancient Hysteria");
                        THSettings.Instance.Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 4) && !THSettings.Instance.Burst) && DebuffCCDuration((WoWUnit) Me, 3000.0, false))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Lose Control");
                        THSettings.Instance.Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 5) && !THSettings.Instance.Burst) && ((Me.HealthPercent < THSettings.Instance.BurstHP) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on My Health Low");
                        THSettings.Instance.Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 6) && !THSettings.Instance.Burst) && (BasicCheck(UnitHeal) && !UnitHeal.IsPet)) && ((HealWeight(UnitHeal) <= THSettings.Instance.BurstHP) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Friend Health Low");
                        THSettings.Instance.Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 7) && !THSettings.Instance.Burst) && (CurrentTargetAttackable(40.0, false, false) && !Me.get_CurrentTarget().IsPet)) && (((Me.HealthPercent > THSettings.Instance.UrgentHeal) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.BurstHP)) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Enemy Health Low");
                        THSettings.Instance.Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 8) && !THSettings.Instance.Burst) && ((Me.ManaPercent < THSettings.Instance.BurstHP) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on My Mana Low");
                        THSettings.Instance.Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 9) && !THSettings.Instance.Burst) && (BuffBurst((WoWUnit) Me) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Using Cooldown");
                        THSettings.Instance.Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey > 9) && (GetAsyncKeyState(Keys.LControlKey) < 0)) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.BurstKey - 9)) < 0) && (LastSwitch.AddSeconds(1.0) < DateTime.Now)))
                    {
                        if (THSettings.Instance.Burst)
                        {
                            THSettings.Instance.Burst = false;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Burst Mode is OFF, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.BurstKey - 8) + " to Turn Burst Mode ON.");
                        }
                        else if (!DebuffCC((WoWUnit) Me))
                        {
                            THSettings.Instance.Burst = true;
                            LastSwitch = DateTime.Now;
                            BurstLast = DateTime.Now.AddSeconds(15.0);
                            Styx.Common.Logging.Write("Burst Mode is ON, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.BurstKey - 8) + " to Turn Burst Mode OFF.");
                        }
                    }
                }
            }
        }

        private static void RebukeVoid()
        {
            if ((THSettings.Instance.Rebuke && (LastInterrupt < DateTime.Now)) && (CanCastCheck("Rebuke") && GetUnitRebuke()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                SafelyFacingTarget(UnitRebuke);
                if ((UnitRebuke.IsCasting && (UnitRebuke.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitRebuke.IsChanneling)
                {
                    CastSpell("Rebuke", UnitRebuke, "Rebuke");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite ReckoningCompProtection()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.AutoTaunt && CanCastCheck("Reckoning")) && GetUnitReckoningProtection(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Reckoning", UnitReckoningProtection, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite ReckoningPvPComp()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AutoTaunt && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Reckoning")) && GetUnitReckoning(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Reckoning", UnitReckoning, "ReckoningPvPComp");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite RepentanceComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.RepentanceCC && (Me.HealthPercent > THSettings.Instance.PriorityHeal)) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Repentance")) && GetUnitRepentance(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Repentance", UnitRepentance, "");
                Blacklist.Add(UnitRepentance.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))), TimeSpan.FromSeconds(1.0), "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite RestRotation()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((Me.ManaPercent < THSettings.Instance.AutoUseFoodHP) && (UseSpecialization == 1)) && (!Me.IsSwimming && !MeHasAura("Drink"))) && (Consumable.GetBestDrink(false) != null), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (!MeHasAura("Drink"))
                {
                    Rest.DrinkImmediate();
                    StyxWoW.SleepForLagDuration();
                }
                if ((MeHasAura("Drink") && ((Me.ManaPercent < THSettings.Instance.DoNotHealAbove) || (BasicCheck(UnitHeal) && (UnitHeal.HealthPercent < THSettings.Instance.UrgentHeal)))) && !Me.Combat)
                {
                    return (RunStatus) RunStatus.Running;
                }
                return (RunStatus) RunStatus.Success;
            })), (Composite) new Decorator(ret => ((!Me.Combat && (((Me.HealthPercent < THSettings.Instance.DoNotHealAbove) && Me.get_CurrentMap().IsBattleground) || (Me.HealthPercent < THSettings.Instance.AutoUseFoodHP))) && (((Me.ManaPercent > 30.0) && !MeHasAura("Drink")) && (!MeHasAura("Food") && (Consumable.GetBestDrink(false) != null)))) && !SpellManager.GlobalCooldown, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if ((CanCastCheck("Holy Light") && !IsMoving((WoWUnit) Me)) && !IsOverrideModeOn)
                {
                    DoNotMove = DateTime.Now + TimeSpan.FromSeconds(3.0);
                    Navigator.get_PlayerMover().MoveStop();
                    WoWMovement.MoveStop();
                    CastSpell("Holy Light", (WoWUnit) Me, "");
                    if ((DoNotMove < DateTime.Now) && !Me.Combat)
                    {
                        return (RunStatus) RunStatus.Running;
                    }
                }
                if ((CanCastCheck("Flash of Light") && !IsMoving((WoWUnit) Me)) && (!IsOverrideModeOn && (Me.ManaPercent > 40.0)))
                {
                    DoNotMove = DateTime.Now + TimeSpan.FromSeconds(1.0);
                    Navigator.get_PlayerMover().MoveStop();
                    WoWMovement.MoveStop();
                    CastSpell("Flash of Light", (WoWUnit) Me, "");
                    if ((DoNotMove < DateTime.Now) && !Me.Combat)
                    {
                        return (RunStatus) RunStatus.Running;
                    }
                }
                return (RunStatus) RunStatus.Success;
            })), (Composite) new Decorator(ret => ((!Me.Combat && (Me.HealthPercent < THSettings.Instance.AutoUseFoodHP)) && (!Me.IsSwimming && !MeHasAura("Food"))) && (Consumable.GetBestFood(false) != null), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (!MeHasAura("Food"))
                {
                    Rest.FeedImmediate();
                    StyxWoW.SleepForLagDuration();
                }
                if ((MeHasAura("Food") && (Me.HealthPercent < THSettings.Instance.DoNotHealAbove)) && !Me.Combat)
                {
                    return (RunStatus) RunStatus.Running;
                }
                return (RunStatus) RunStatus.Success;
            })) };
            return (Composite) new Decorator(ret => (((THSettings.Instance.AutoUseFood && !Me.IsDead) && (!Me.IsGhost && !Me.Combat)) && (!Me.IsCasting && !IsOverrideModeOn)) && !IsMoving((WoWUnit) Me), (Composite) new PrioritySelector(compositeArray));
        }

        private Composite RestSelector()
        {
            if (this._restBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing rest behaviours.");
                this._restBehavior = (Composite) new PrioritySelector(new Composite[] { RestRotation() });
            }
            return null;
        }

        private static Composite RetributionRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                AutoTarget(), BubbleFlashofLightRet(), MovementMoveToMelee(ret => Me.get_CurrentTarget()), MovementMoveStop(ret => Me.get_CurrentTarget(), 3.0), LayonHands(), AvengingWrathBurstRet(), HolyAvengerBurstRet(), DivineProtection(), ReckoningPvPComp(), DevotionAura(), UseHealthStoneHP(), UseBattleStandard(), HammerofJusticeEnemyLow(), HammerofJusticeEnemyUsingCD(), DivineShield(), HandofProtectionMe(), 
                HandofSacrificeFriendRetRemoveCC(), HandofProtectionFriendRemoveCC(), HandofProtectionFriend(), HandofFreedomMyself(), Emancipate(), HandofPurity(), FlashofLightSelflessHealer(), FlashofLightSelflessHealerExpiring(), CrowdControlHPSurviveComp(), TurnEvilASAPComp(), GuardianofAncientKingsRet(), SealofTruth(), SealofTruthfromRighteousness(), SealofRighteousness(), JudgementRangeRetPvP(), Inquisition(), 
                HolyPrism(), LightHammer(), ExecutionSentence(), JudgementRangeRetPvE(), WordofGloryMeRet(), HammerofWrathCurrentTarget(), HammerofWrathofTarget(), DivineStorm5HolyPower(), TemplarsVerdict5HolyPower(), AttackASAPRotationInstantComp(), Exorcism(), HammeroftheRighteousRet(), CrusaderStrikeRet(), JudgementRet(), DivineStorm3HolyPower(), TemplarsVerdict3HolyPower(), 
                SacredShieldMeRet(), WordofGloryFriendRet(), TurnEvilComp(), SacredShieldFriendRet(), RepentanceComp(), HandofSacrificeFriend(), HandofFreedomFriend(), WordofGloryMeTopUpRet(), FlashofLightMeRet(), FlashofLightFriendRet(), InquisitionMeTopUp(), FlashofLightMeTopUpRet(), BuffRotation(), RighteousFury(), DivinePlea(), AutoRez()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite RighteousFury()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.AutoRighteousFury && (((UseSpecialization == 2) && ((Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid) || (Me.get_CurrentMap().Name == "Proving Grounds"))) || (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground))) && !MeHasAura("Righteous Fury")) && CanCastCheck("Righteous Fury"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Righteous Fury", (WoWUnit) Me, "");
            })), (Composite) new Decorator(ret => ((THSettings.Instance.AutoRighteousFury && (UseSpecialization != 2)) && (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)) && MeHasAura("Righteous Fury"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CancelAura(0x64b4, (WoWUnit) Me);
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private Composite RotationSelector()
        {
            if (this._combatBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing combat behaviours.");
                this._combatBehavior = (Composite) new PrioritySelector(new Composite[] { MainRotation() });
            }
            return null;
        }

        private static Composite SacredShieldFriendRet()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.SacredShieldRet && (Me.HealthPercent > THSettings.Instance.PriorityHeal)) && (UnitHealIsValid && (HealWeightUnitHeal < (Me.HealthPercent - 20.0)))) && !MyAura("Sacred Shield", UnitHeal)) && CanCastCheck("Sacred Shield"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Sacred Shield", UnitHeal, "");
            }));
        }

        private static Composite SacredShieldHoly()
        {
            return (Composite) new Decorator(ret => ((Me.Combat || Me.IsInInstance) && (CanCastCheck("Sacred Shield") && GetUnitToSacredShield())) && !MyAura("Sacred Shield", UnitToSacredShield), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Sacred Shield", UnitToSacredShield, "");
            }));
        }

        private static Composite SacredShieldMeProt()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.SacredShieldProtMe && !MeHasAura("Hand of Protection")) && !MeHasAura("Divine Shield")) && ((Me.Combat || Me.get_CurrentMap().IsDungeon) || Me.get_CurrentMap().IsRaid)) && (MyAuraTimeLeft("Sacred Shield", (WoWUnit) Me) < 2000.0)) && CanCastCheck("Sacred Shield"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Sacred Shield", (WoWUnit) Me, "");
            }));
        }

        private static Composite SacredShieldMeRet()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.SacredShieldRetMe || MeHasAura("Hand of Protection")) || (MeHasAura("Divine Shield") || !CanCastCheck("Sacred Shield"))) || (((!Me.Combat || (Me.HealthPercent >= THSettings.Instance.PriorityHeal)) && (!Me.get_CurrentMap().IsArena || GetUnitHaveMySacredShield())) && (!Me.get_CurrentMap().IsBattleground || GetUnitHaveMySacredShield())))
                {
                    return false;
                }
                if (MeHasAura("Sacred Shield"))
                {
                    return MyAuraTimeLeft("Sacred Shield", (WoWUnit) Me) < 2000.0;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Sacred Shield", (WoWUnit) Me, "");
            }));
        }

        private static Composite SacredShieldTankProt()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.SacredShieldProt && CanCastCheck("Sacred Shield")) && GetUnitSacredShieldProt()) && (CountEnemyTargettingUnit((WoWUnit) Me, 40f) <= 0.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Sacred Shield", UnitSacredShieldProt, "SacredShieldProt");
            }));
        }

        private static void SafelyFacingTarget(WoWUnit target)
        {
            if (BasicCheck(target) && ((THSettings.Instance.AutoFace && !IsOverrideModeOn) && !Me.IsSafelyFacing((WoWObject) target)))
            {
                Me.SetFacing(target.get_Location());
            }
        }

        private static bool SafeUsingCooldown(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return !target.GetAllAuras().Any<WoWAura>(aura => SafeUsingCooldownHS.Contains(aura.SpellId));
        }

        private static Composite SealofInsight()
        {
            return (Composite) new Decorator(ret => (((SealSwitchLast < DateTime.Now) && !MeHasAura("Seal of Insight")) && !MeHasAura("Seal of Truth")) && CanCastCheck("Seal of Insight"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Insight", (WoWUnit) Me, "");
            }));
        }

        private static Composite SealofRighteousness()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.SealofRighteousnessRet && (SealSwitchLast < DateTime.Now)) && (!Me.get_CurrentMap().IsBattleground && !Me.get_CurrentMap().IsArena)) && (!MeHasAura("Seal of Righteousness") && CanCastCheck("Seal of Righteousness"))) && (CountEnemyNear((WoWUnit) Me, 8f) >= THSettings.Instance.SealofRighteousnessRetNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Righteousness", (WoWUnit) Me, "");
            }));
        }

        private static Composite SealofTruth()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((SealSwitchLast < DateTime.Now) && !MeHasAura("Seal of Truth")) && (!MeHasAura("Seal of Righteousness") && !MeHasAura("Seal of Justice"))) && !MeHasAura("Seal of Insight")) && CanCastCheck("Seal of Truth"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Truth", (WoWUnit) Me, "");
            })), (Composite) new Decorator(ret => (((SealSwitchLast < DateTime.Now) && !SpellManager.HasSpell("Seal of Truth")) && !MeHasAura("Seal of Command")) && CanCastCheck("Seal of Command"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Command", (WoWUnit) Me, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite SealofTruthfromRighteousness()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.SealofRighteousnessRet && (SealSwitchLast < DateTime.Now)) && (!MeHasAura("Seal of Truth") && !MeHasAura("Seal of Justice"))) && (!MeHasAura("Seal of Insight") && CanCastCheck("Seal of Truth"))) && (CountEnemyNear((WoWUnit) Me, 8f) <= THSettings.Instance.SealofRighteousnessRetNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Truth", (WoWUnit) Me, "SealofTruthfromRighteousness");
            }));
        }

        private static Composite SealProtection()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((SealSwitchLast < DateTime.Now) && !MeHasAura("Seal of Command")) && CanCastCheck("Seal of Command"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Command", (WoWUnit) Me, "");
            })), (Composite) new Decorator(ret => (((SealSwitchLast < DateTime.Now) && !MeHasAura("Seal of Truth")) && (!MeHasAura("Seal of Righteousness") && !MeHasAura("Seal of Insight"))) && CanCastCheck("Seal of Insight"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Insight", (WoWUnit) Me, "");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.SealofRighteousnessProt && (SealSwitchLast < DateTime.Now)) && (Me.Combat && !MeHasAura("Seal of Righteousness"))) && CanCastCheck("Seal of Righteousness")) && (CountEnemyNear((WoWUnit) Me, 8f) >= THSettings.Instance.SealofRighteousnessProtNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (MeHasAura("Seal of Truth"))
                {
                    ProtPreferedSeal = "Seal of Truth";
                }
                else if (MeHasAura("Seal of Command"))
                {
                    ProtPreferedSeal = "Seal of Command";
                }
                else if (MeHasAura("Seal of Insight"))
                {
                    ProtPreferedSeal = "Seal of Insight";
                }
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell("Seal of Righteousness", (WoWUnit) Me, "SealofRighteousnessProt");
            })), (Composite) new Decorator(ret => (((SealSwitchLast < DateTime.Now) && (ProtPreferedSeal != null)) && (MeHasAura("Seal of Righteousness") && CanCastCheck(ProtPreferedSeal))) && (CountEnemyNear((WoWUnit) Me, 8f) <= THSettings.Instance.SealofRighteousnessRetNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SealSwitchLast = DateTime.Now + TimeSpan.FromSeconds(10.0);
                CastSpell(ProtPreferedSeal, (WoWUnit) Me, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite SetAutoAttack()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((Me.get_CurrentTarget() != null) && (SetAutoAttackLast < DateTime.Now)) && !CurrentTargetAttackable(50.0, false, false))
                {
                    Lua.DoString("RunMacroText('/stopattack');", "WoW.lua");
                    SetAutoAttackLast = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                    return (RunStatus) RunStatus.Failure;
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite ShieldoftheRighteous()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.ShieldofRighterous || (Me.get_Inventory().get_Equipped().get_OffHand() == null)) || ((Me.HealthPercent <= THSettings.Instance.WordofGloryMeRetHP) || MeHasAura("Hand of Protection"))) || ((!CurrentTargetAttackable(5.0, false, false) || !FacingOverride(Me.get_CurrentTarget())) || ((PlayerHolyPower < THSettings.Instance.ShieldofRighterousHP) && !MeHasAura(0x1603e))))
                {
                    return false;
                }
                return CanCastCheck("Shield of the Righteous");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Shield of the Righteous", Me.get_CurrentTarget(), "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite SpeedofLight()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.SpeedofLight && IsMoving((WoWUnit) Me)) && (!DebuffRootorSnare((WoWUnit) Me) && CanCastCheck("Speed of Light"))) && HasEnemyPlayerNear((WoWUnit) Me, (float) THSettings.Instance.SpeedofLightDistance), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Speed of Light", (WoWUnit) Me, "SpeedofLight");
            }));
        }

        private static WoWSpell SpellFind(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return null;
            }
            return (results.Override ?? results.Original);
        }

        private static bool SpellOnCooldown(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return false;
            }
            if (results.Override == null)
            {
                return results.Original.Cooldown;
            }
            return results.Override.Cooldown;
        }

        private static bool SpellOnCooldown(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return false;
            }
            if (results.Override == null)
            {
                return results.Original.Cooldown;
            }
            return results.Override.Cooldown;
        }

        private static void SpellsCooldownCacheAdd(string spellName, DateTime CooldownBack)
        {
            if ((spellName == "Hammer of the Righteous") || (spellName == "Crusader Strike"))
            {
                SpellsCooldownCache.Add("Hammer of the Righteous", CooldownBack);
                SpellsCooldownCache.Add("Crusader Strike", CooldownBack);
            }
            else if (spellName.Contains("Seal"))
            {
                SpellsCooldownCache.Add("Seal of Truth", CooldownBack);
                SpellsCooldownCache.Add("Seal of Command", CooldownBack);
                SpellsCooldownCache.Add("Seal of Insight", CooldownBack);
                SpellsCooldownCache.Add("Seal of Righteousness", CooldownBack);
                SpellsCooldownCache.Add("Seal of Justice", CooldownBack);
            }
            else
            {
                SpellsCooldownCache.Add(spellName, CooldownBack);
            }
        }

        private static void SpellsCooldownCacheClear()
        {
            if (MeHasAura("Arena Preparation"))
            {
                SpellsCooldownCache.Clear();
            }
            else
            {
                foreach (string str in (from unit in SpellsCooldownCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<string>())
                {
                    try
                    {
                        SpellsCooldownCache.Remove(str);
                        continue;
                    }
                    catch (Exception)
                    {
                        Styx.Common.Logging.Write("Fail to SpellsCooldownCache.Remove({0})", new object[] { str });
                        throw;
                    }
                }
            }
        }

        private static void SpellsCooldownCacheClearSpell(string spellName)
        {
            foreach (string str in (from unit in SpellsCooldownCache
                where unit.Key == spellName
                select unit.Key).ToList<string>())
            {
                try
                {
                    SpellsCooldownCache.Remove(str);
                    continue;
                }
                catch (Exception)
                {
                    Styx.Common.Logging.Write("Fail to SpellsCooldownCache.Remove({0})", new object[] { str });
                    throw;
                }
            }
        }

        private void StopCastingCheck()
        {
            if (((((StopCastingCheckLast <= DateTime.Now) || Me.get_CurrentMap().IsArena) && (((LastCastTime + TimeSpan.FromMilliseconds(2000.0)) >= DateTime.Now) && ((THSettings.Instance.Hotkey1Key == 0) || (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey1Key)) >= 0)))) && (((THSettings.Instance.Hotkey2Key == 0) || (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey2Key)) >= 0)) && ((THSettings.Instance.Hotkey3Key == 0) || (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey3Key)) >= 0)))) && (((THSettings.Instance.Hotkey4Key == 0) || (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey4Key)) >= 0)) && ((THSettings.Instance.Hotkey5Key == 0) || (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Hotkey5Key)) >= 0))))
            {
                StopCastingCheckLast = DateTime.Now + TimeSpan.FromMilliseconds(50.0);
                if (Me.IsCasting)
                {
                    if ((((LastCastSpell == "Divine Light") && (Me.get_CastingSpell().Name == "Divine Light")) && BasicCheck(LastCastUnit)) && ((HealWeight(LastCastUnit) >= (THSettings.Instance.DoNotHealAbove - THSettings.Instance.HealBalancing)) || (HealWeight(LastCastUnit) >= (THSettings.Instance.DivineLightHP + 0x19))))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting: Save Mana Divine Light");
                    }
                    if ((((UseSpecialization == 1) && (LastCastSpell == "Flash of Light")) && ((Me.get_CastingSpell().Name == "Flash of Light") && BasicCheck(LastCastUnit))) && ((HealWeight(LastCastUnit) >= (THSettings.Instance.DoNotHealAbove - THSettings.Instance.HealBalancing)) || (HealWeight(LastCastUnit) >= (THSettings.Instance.FlashofLightHolyHP + 20))))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting: Save Mana Flash of Light");
                    }
                    if ((((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && ((LastCastSpell == "Holy Light") && (Me.get_CastingSpell().Name == "Holy Light"))) && (BasicCheck(LastCastUnit) && (LastCastUnit.Combat || Me.Combat))) && ((Me.CurrentCastTimeLeft.TotalMilliseconds > 1300.0) && (HealWeight(LastCastUnit) < THSettings.Instance.DivineLightHP)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting Holy Light. Need Faster Heal!");
                    }
                    if ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena) && (((LastCastSpell == "Divine Light") && (Me.get_CastingSpell().Name == "Divine Light")) && !MeHasAura(0xd385)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting " + LastCastSpell + ": No Infusion of Light");
                    }
                    if (((LastCastSpell == "Denounce") && (Me.get_CastingSpell().Name == "Denounce")) && (BasicCheck(LastCastUnit) && DebuffCCBreakonDamage(LastCastUnit)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting: Unit Have Debuff Break on Damage");
                    }
                    if (((LastCastSpell == "Denounce") && (Me.get_CastingSpell().Name == "Denounce")) && (UnitHealIsValid && (HealWeightUnitHeal < THSettings.Instance.PriorityHeal)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting Denounce: Need Heal First");
                    }
                    if (((LastCastSpell == "Repentance") && (Me.get_CastingSpell().Name == "Repentance")) && (BasicCheck(LastCastUnit) && DebuffCC(LastCastUnit)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting: Unit is Croud Controlled");
                    }
                    if (((LastCastSpell == "Repentance") && (Me.get_CastingSpell().Name == "Repentance")) && (UnitHealIsValid && (HealWeightUnitHeal < THSettings.Instance.PriorityHeal)))
                    {
                        SpellManager.StopCasting();
                        Styx.Common.Logging.Write(DateTime.Now.ToString("ss:fff ") + "Stop Casting Denounce: Need Heal First");
                    }
                }
            }
        }

        private static void SVNCheck()
        {
            try
            {
                Styx.Common.Logging.Write("Newest SVN Revision: " + GetSVNRevision());
            }
            catch (Exception)
            {
                Styx.Common.Logging.Write("Can not get GetSVNRevision");
                return;
            }
            try
            {
                Styx.Common.Logging.Write("You are using Revision: " + GetLocalRevision());
            }
            catch (Exception)
            {
                Styx.Common.Logging.Write("Can not get GetLocalRevision");
                return;
            }
            if (((GetLocalRevision() != 0) && (GetSVNRevision() != 0)) && (GetSVNRevision() != GetLocalRevision()))
            {
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("A newer version with Improved Logic");
                Styx.Common.Logging.Write("And Bug Fix just uploaded to SVN server!");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Please update to the lastest Revision " + GetSVNRevision());
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("To Update please Close Honorbuddy");
                Styx.Common.Logging.Write("Then open folder");
                Styx.Common.Logging.Write(Path.Combine(Utilities.AssemblyDirectory, "Routines"));
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Right Click Folder " + CombatRoutineFolder);
                Styx.Common.Logging.Write(" > SVN Update working copy. (If you see that option)");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Right Click Folder " + CombatRoutineFolder);
                Styx.Common.Logging.Write(" > SVN Update");
                Styx.Common.Logging.Write("----------------------------------");
            }
        }

        private static byte TalentSort(WoWUnit target)
        {
            if ((target != null) && target.IsValid)
            {
                switch (target.get_Class())
                {
                    case WoWClass.Warrior:
                        return 1;

                    case WoWClass.Paladin:
                        if (target.MaxMana <= (target.MaxHealth / 2))
                        {
                            return 1;
                        }
                        return 4;

                    case WoWClass.Hunter:
                        return 2;

                    case WoWClass.Rogue:
                        return 1;

                    case WoWClass.Priest:
                        if (!UnitHasAura(0x1c0c4, target))
                        {
                            return 4;
                        }
                        return 3;

                    case WoWClass.DeathKnight:
                        return 1;

                    case WoWClass.Shaman:
                        if (target.MaxMana >= (target.MaxHealth / 2))
                        {
                            if (UnitHasAura(0x3f55, target))
                            {
                                return 4;
                            }
                            return 3;
                        }
                        return 1;

                    case WoWClass.Mage:
                        return 3;

                    case WoWClass.Warlock:
                        return 3;

                    case WoWClass.Monk:
                        if (!UnitHasAura(0x1c17e, target))
                        {
                            return 1;
                        }
                        return 4;

                    case WoWClass.Druid:
                        if (target.MaxMana >= (target.MaxHealth / 2))
                        {
                            if (UnitHasAura(0x1a0ef, target))
                            {
                                return 4;
                            }
                            return 3;
                        }
                        return 1;
                }
            }
            return 0;
        }

        private static string TalentSortRole(WoWUnit target)
        {
            switch (TalentSort(target))
            {
                case 1:
                    return "Melee";

                case 2:
                    return "Range DPS";

                case 3:
                    return "Range DPS";

                case 4:
                    return "Healer";
            }
            return "Unknow";
        }

        private static byte TalentSortSimple(WoWUnit target)
        {
            byte num = TalentSort(target);
            if (num == 4)
            {
                return 4;
            }
            if ((num < 4) && (num > 0))
            {
                return 1;
            }
            return 0;
        }

        private static Composite TemplarsVerdict3HolyPower()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.TemplarsVerdict || MeHasAura("Hand of Protection")) || ((MyAuraTimeLeft(0x14be3, (WoWUnit) Me) <= 7000.0) || !CurrentTargetAttackable(5.0, false, false))) || (!FacingOverride(Me.get_CurrentTarget()) || ((PlayerHolyPower < 3.0) && !MeHasAura(0x1603e))))
                {
                    return false;
                }
                return CanCastCheck("Templar's Verdict");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Templar's Verdict", Me.get_CurrentTarget(), "Templar's Verdict");
            }));
        }

        private static Composite TemplarsVerdict5HolyPower()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.TemplarsVerdict || MeHasAura("Hand of Protection")) || (!CurrentTargetAttackable(5.0, false, false) || !FacingOverride(Me.get_CurrentTarget()))) || (((PlayerHolyPower < Me.MaxHolyPower) && !MeHasAura(0x1603e)) && ((PlayerHolyPower < 3.0) || !MeHasAura("Holy Avenger"))))
                {
                    return false;
                }
                return CanCastCheck("Templar's Verdict");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Templar's Verdict", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite TurnEvilASAPComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.TurnEvilASAP && Me.Combat) && CanCastCheck("Turn Evil")) && GetUnitTurnEvilASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Turn Evil", UnitTurnEvilASAP, "");
                UnitTurnEvilASAP = null;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite TurnEvilComp()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.TurnEvil && Me.Combat) && CanCastCheck("Turn Evil")) && GetUnitTurnEvil(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Turn Evil", UnitTurnEvil, "");
                UnitTurnEvilASAP = null;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static bool UnitHasAura(int auraID, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => (aura.SpellId == auraID));
        }

        private static bool UnitHasAura(string auraName, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => (aura.Name == auraName));
        }

        private static void UpdateEventHandler()
        {
            if (((IsUsingAFKBot && !Me.get_CurrentMap().IsArena) && (!Me.get_CurrentMap().IsBattleground && !Me.get_CurrentMap().IsDungeon)) && (!Me.get_CurrentMap().IsRaid && !EventHandlers.CombatLogAttached))
            {
                EventHandlers.AttachCombatLogEvent();
            }
            if (((!IsUsingAFKBot || Me.get_CurrentMap().IsArena) || ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsDungeon) || Me.get_CurrentMap().IsRaid)) && EventHandlers.CombatLogAttached)
            {
                EventHandlers.DetachCombatLogEvent();
            }
        }

        private static void UpdateGroupChangeEvent(object sender, LuaEventArgs args)
        {
            if (IGroupHealingOn())
            {
                Styx.Common.Logging.Write("Update Selective Group Healing on Group Member Change");
                UpdateGroupHealingMembers();
            }
        }

        private static void UpdateGroupHealingMembers()
        {
            GroupHealingMembers.Clear();
            if (IGroupHealingOn())
            {
                foreach (WoWPartyMember member in GroupMembers)
                {
                    if ((member.ToPlayer() == null) || ((((!THSettings.Instance.Group1 || (member.GroupNumber != 0)) && (!THSettings.Instance.Group2 || (member.GroupNumber != 1))) && ((!THSettings.Instance.Group3 || (member.GroupNumber != 2)) && (!THSettings.Instance.Group4 || (member.GroupNumber != 3)))) && (((!THSettings.Instance.Group5 || (member.GroupNumber != 4)) && (!THSettings.Instance.Group6 || (member.GroupNumber != 5))) && ((!THSettings.Instance.Group7 || (member.GroupNumber != 6)) && (!THSettings.Instance.Group8 || (member.GroupNumber != 7))))))
                    {
                        continue;
                    }
                    Styx.Common.Logging.Write(string.Concat(new object[] { "Add ", member.ToPlayer().get_Class(), " in Group: ", Convert.ToByte(member.GroupNumber) + 1, " to Selective Group Healing" }));
                    GroupHealingMembers.Add(member.ToPlayer());
                }
                if (GroupHealingMembers.Any<WoWPlayer>())
                {
                    Styx.Common.Logging.Write("----------------------------------");
                    Styx.Common.Logging.Write("You are assigned to Heal " + GroupHealingMembers.Count<WoWPlayer>() + " Members");
                    Styx.Common.Logging.Write("You will also heal your Target, your Focus and Yourself!");
                    Styx.Common.Logging.Write("----------------------------------");
                }
            }
        }

        private static void UpdateMyGlyph()
        {
            HasGlyph = "";
            HasGlyphName = "";
            int returnVal = Lua.GetReturnVal<int>("return GetNumGlyphSockets()", 0);
            if (returnVal != 0)
            {
                for (int i = 1; i <= returnVal; i++)
                {
                    int num3 = Lua.GetReturnVal<int>(string.Format("local enabled, glyphType, glyphTooltipIndex, glyphSpellID, icon = GetGlyphSocketInfo({0});if (enabled) then return glyphSpellID else return 0 end", i), 0);
                    try
                    {
                        if (num3 > 0)
                        {
                            HasGlyphName = string.Concat(new object[] { HasGlyphName, "[", WoWSpell.FromId(num3), " - ", num3, "] " });
                            HasGlyph = string.Concat(new object[] { HasGlyph, "[", num3, "] " });
                        }
                        else
                        {
                            Styx.Common.Logging.Write("Glyphdetection - No Glyph in slot " + i);
                        }
                    }
                    catch (Exception exception)
                    {
                        Styx.Common.Logging.Write("We couldn't detect your Glyphs");
                        Styx.Common.Logging.Write("Report this message to us: " + exception);
                    }
                }
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Glyph:");
            Styx.Common.Logging.Write(HasGlyphName);
            Styx.Common.Logging.Write("----------------------------------");
        }

        private static void UpdateMyGlyphEvent(object sender, LuaEventArgs args)
        {
            UpdateMyGlyph();
        }

        private static void UpdateMyLatency()
        {
            MyLatency = StyxWoW.get_WoWClient().Latency;
            if (MyLatency > 400.0)
            {
                MyLatency = 400.0;
            }
        }

        private static void UpdateMyTalent()
        {
            _hasTalent = "";
            for (int i = 1; i <= 0x12; i++)
            {
                _hasTalent = _hasTalent + Lua.GetReturnVal<string>(string.Format("local t= select(5,GetTalentInfo({0})) if t == true then return '['..select(1,GetTalentInfo({0}))..'] ' end return nil", i), 0);
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Talent:");
            Styx.Common.Logging.Write(_hasTalent);
            Styx.Common.Logging.Write("----------------------------------");
            _hasTalent = "";
        }

        private static void UpdateMyTalentEvent(object sender, LuaEventArgs args)
        {
            UpdateMyTalent();
        }

        private void UpdateStatus()
        {
            if (THSettings.Instance.UpdateStatus)
            {
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Building Rotation base on current Talents and Glyphs......");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                UpdateEventHandler();
                UpdateMyTalent();
                UpdateMyGlyph();
                UpdateMyLatency();
                UpdateGroupHealingMembers();
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Hold 1 second Control + " + IndexToKeys(THSettings.Instance.PauseKey) + " To Toggle Pause Mode.");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                if (THSettings.Instance.BurstKey > 9)
                {
                    Styx.Common.Logging.Write("----------------------------------");
                    Styx.Common.Logging.Write("Hold 1 second Control + " + IndexToKeys(THSettings.Instance.BurstKey - 9) + " To Toggle Burst Mode");
                    Styx.Common.Logging.Write("----------------------------------");
                    Styx.Common.Logging.Write("");
                }
                if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.PaladinHoly)))
                {
                    UseSpecialization = 1;
                }
                else if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.PaladinProtection)))
                {
                    UseSpecialization = 2;
                }
                else
                {
                    UseSpecialization = 3;
                }
                if ((((TreeRoot.get_Current().Name == "Questing") || (TreeRoot.get_Current().Name == "[BETA] Grindbuddy")) || ((TreeRoot.get_Current().Name == "ArcheologyBuddy") || (TreeRoot.get_Current().Name == "Auto Angler"))) || (((TreeRoot.get_Current().Name == "Gatherbuddy2") || (TreeRoot.get_Current().Name == "Grind Bot")) || (((TreeRoot.get_Current().Name == "BGBuddy") || (TreeRoot.get_Current().Name == "DungeonBuddy")) || (TreeRoot.get_Current().Name == "Mixed Mode"))))
                {
                    IsUsingAFKBot = true;
                }
                else
                {
                    IsUsingAFKBot = false;
                }
                MeGuid = Me.Guid;
                MeMaxHealth = Me.MaxHealth;
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Building Rotation Completed");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                SVNCheck();
                THSettings.Instance.UpdateStatus = false;
            }
        }

        private static void UpdateStatusEvent(object sender, LuaEventArgs args)
        {
            THSettings.Instance.UpdateStatus = true;
        }

        private static Composite UseBattleStandard()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BattleStandard && Me.Combat) && ((Me.HealthPercent <= THSettings.Instance.BattleStandardHP) && (Me.get_CurrentTarget() != null))) && (Me.get_CurrentTarget().HealthPercent > Me.HealthPercent)) && Me.get_CurrentMap().IsBattleground, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsAlliance)
                {
                    WoWItem item = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x48ae);
                    if ((!MeHasAura("Alliance Battle Standard") && (item != null)) && (item.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                    {
                        item.Use();
                        Styx.Common.Logging.Write("Use Battle Standard at " + Me.HealthPercent + "%");
                    }
                }
                if (Me.IsHorde)
                {
                    WoWItem item2 = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x48af);
                    if ((!MeHasAura("Horde Battle Standard") && (item2 != null)) && (item2.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                    {
                        item2.Use();
                        Styx.Common.Logging.Write("Use Battle Standard at " + Me.HealthPercent + "%");
                    }
                }
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite UseHealthStoneHP()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HealthStone && Me.Combat) && ((Me.HealthPercent < THSettings.Instance.HealthStoneHP) && (Me.get_CurrentTarget() != null))) && (Me.get_CurrentTarget().HealthPercent > Me.HealthPercent), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                WoWItem item = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x1588);
                if ((item != null) && (item.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                {
                    item.Use();
                    Styx.Common.Logging.Write("Use HealthStoneHP at " + Me.HealthPercent + "%");
                }
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite UseProfession()
        {
            Composite[] compositeArray = new Composite[] { 
                (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 1) && Me.Combat) && (Me.get_Inventory().get_Equipped().get_Hands() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 2) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && CurrentTargetAttackable(30.0, false, false))) && Me.get_CurrentTarget().IsBoss) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Cooldown (Boss Only");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 3) && THSettings.Instance.Burst) && (Me.Combat && (Me.get_Inventory().get_Equipped().get_Hands() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Burst Mode");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 4) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && CurrentTargetAttackable(30.0, false, false))) && DebuffCCDuration((WoWUnit) Me, 3000.0, false)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Lose Control");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && (Me.HealthPercent < THSettings.Instance.ProfBuffHP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: GLoves Buff Activated on Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && UnitHealIsValid)) && (HealWeightUnitHeal <= THSettings.Instance.ProfBuffHP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Friendly Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 7) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && CurrentTargetAttackable(20.0, false, false))) && (!Me.get_CurrentTarget().IsPet && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.ProfBuffHP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Enemy Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 8) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && (Me.ManaPercent <= THSettings.Instance.ProfBuffHP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Low Mana");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 9) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && BuffBurst((WoWUnit) Me))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Gloves Buff Activated on Using Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                    LastCastSpell = "SProfBuff";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((THSettings.Instance.ProfBuff == 1) && Me.Combat) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Cooldown");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 2) && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && Me.get_CurrentTarget().IsBoss)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Cooldown (Boss Only");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 3) && THSettings.Instance.Burst) && Me.Combat) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Burst Mode");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 4) && Me.Combat) && DebuffCCDuration((WoWUnit) Me, 3000.0, false)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Lose Control");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 5) && Me.Combat) && (Me.HealthPercent <= THSettings.Instance.ProfBuffHP)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Low HP");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 6) && Me.Combat) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.ProfBuffHP))) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Friendly Unit Low HP");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 7) && Me.Combat) && (CurrentTargetAttackable(20.0, false, false) && !Me.get_CurrentTarget().IsPet)) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.ProfBuffHP)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Enemy Unit Low HP");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), 
                (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 8) && Me.Combat) && (Me.ManaPercent <= THSettings.Instance.ProfBuffHP)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Low Mana");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 9) && Me.Combat) && BuffBurst((WoWUnit) Me)) && CanCastCheck("Lifeblood"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Use: Lifeblood Activated on Using Cooldown");
                    CastSpell("Lifeblood", (WoWUnit) Me, "");
                    return (RunStatus) RunStatus.Failure;
                }))
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite UseRacial()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.AutoRacial && Me.Combat) && (!MeHasAura("Sap Flag") && !MeHasAura("Scatter Shot"))) && DebuffCCDuration((WoWUnit) Me, 3000.0, false)) && CanCastCheck("Every Man for Himself"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if ((THSettings.Instance.AutoTarget && (Me.get_CurrentTarget() == null)) && BasicCheck(MyLastTarget))
                {
                    MyLastTarget.Target();
                }
                if (DebuffCCBreakonDamage((WoWUnit) Me) && DebuffDot((WoWUnit) Me))
                {
                    Styx.Common.Logging.Write("Waiting for Dot / Hand of Sacrifice break it!");
                }
                else
                {
                    Styx.Common.Logging.Write("Use: Every Man for Himself");
                    CastSpell("Every Man for Himself", (WoWUnit) Me, "");
                }
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((THSettings.Instance.AutoRacial && (Me.HealthPercent < THSettings.Instance.UrgentHeal)) && Me.Combat) && CanCastCheck("Stoneform"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Stoneform");
                CastSpell("Stoneform", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((THSettings.Instance.AutoRacial && (Me.HealthPercent < THSettings.Instance.UrgentHeal)) && Me.Combat) && CanCastCheck("Gift of the Naaru"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Gift of the Naaru");
                CastSpell("Gift of the Naaru", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AutoRacial || (Me.ManaPercent >= THSettings.Instance.PriorityHeal)) || ((UseSpecialization != 1) || !Me.Combat)) || (!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid))
                {
                    return false;
                }
                return CanCastCheck("Arcane Torrent");
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Arcane Torrent");
                CastSpell("Arcane Torrent", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite UseTrinket()
        {
            Composite[] compositeArray = new Composite[] { 
                (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 1) && Me.Combat) && (Me.get_Inventory().get_Equipped().get_Trinket1() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 2) && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && Me.get_CurrentTarget().IsBoss)) && (Me.get_Inventory().get_Equipped().get_Trinket1() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Cooldown (Boss Only");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 3) && THSettings.Instance.Burst) && (Me.Combat && (Me.get_Inventory().get_Equipped().get_Trinket1() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Burst Mode");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 4) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && !MeHasAura("Scatter Shot"))) && (!MeHasAura("Sap") && DebuffCCDuration((WoWUnit) Me, 3000.0, false))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Lose Control");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && (Me.HealthPercent < THSettings.Instance.Trinket1HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && UnitHealIsValid)) && (HealWeightUnitHeal <= THSettings.Instance.Trinket1HP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Friendly Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 7) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && CurrentTargetAttackable(20.0, false, false))) && (!Me.get_CurrentTarget().IsPet && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.Trinket1HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Enemy Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 8) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && (Me.ManaPercent <= THSettings.Instance.Trinket1HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Low Mana");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 9) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && BuffBurst((WoWUnit) Me))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Using Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                    LastCastSpell = "STrinket1";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 1) && Me.Combat) && (Me.get_Inventory().get_Equipped().get_Trinket2() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 2) && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && Me.get_CurrentTarget().IsBoss)) && (Me.get_Inventory().get_Equipped().get_Trinket2() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Cooldown (Boss Only");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 3) && THSettings.Instance.Burst) && (Me.Combat && (Me.get_Inventory().get_Equipped().get_Trinket2() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Burst Mode");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 4) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && !MeHasAura("Scatter Shot"))) && (!MeHasAura("Sap") && DebuffCCDuration((WoWUnit) Me, 3000.0, false))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Lose Control");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && (Me.HealthPercent <= THSettings.Instance.Trinket2HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && UnitHealIsValid)) && (HealWeightUnitHeal <= THSettings.Instance.Trinket2HP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Friendly Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 7) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && CurrentTargetAttackable(20.0, false, false))) && (!Me.get_CurrentTarget().IsPet && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.Trinket2HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Enemy Unit Low HP");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), 
                (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 8) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && (Me.ManaPercent <= THSettings.Instance.Trinket2HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Low Mana");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 9) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && BuffBurst((WoWUnit) Me))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Using Cooldown");
                    StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                    LastCastSpell = "STrinket2";
                    return (RunStatus) RunStatus.Failure;
                }))
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private void WarStompVoid()
        {
            if (((THSettings.Instance.AutoRacial && (LastInterrupt < DateTime.Now)) && (UnitHealIsValid && (HealWeightUnitHeal > THSettings.Instance.PriorityHeal))) && (CanCastCheck("War Stomp") && GetUnitWarStomp()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitWarStomp.IsCasting && (UnitRebuke.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 600.0))) || UnitWarStomp.IsChanneling)
                {
                    CastSpell("War Stomp", (WoWUnit) Me, "War Stomp");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static Composite WordofGloryFriendProt()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.WordofGloryFriendProt && !SpellManager.HasSpell("Eternal Flame")) && Me.Combat) && ((PlayerHolyPower >= THSettings.Instance.WordofGloryFriendProtHolyPower) || MeHasAura(0x1603e))) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.WordofGloryFriendProtHP))) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Word of Glory", UnitHeal, "WordofGloryFriendProt");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.WordofGloryFriendProt && Me.Combat) && ((PlayerHolyPower >= THSettings.Instance.WordofGloryFriendProtHolyPower) || MeHasAura(0x1603e))) && ((UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.WordofGloryFriendProtHP)) && (MyAuraTimeLeft(0x1bdf3, UnitHeal) < 2000.0))) && CanCastCheck("Eternal Flame"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Eternal Flame", UnitHeal, "Eternal Flame - WordofGloryFriendProt");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite WordofGloryFriendRet()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.WordofGloryFriendRet && !SpellManager.HasSpell("Eternal Flame")) && Me.Combat) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && (((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.WordofGloryFriendRetHP))) && (MyAuraTimeLeft(0x1bdf3, UnitHeal) < 2000.0))) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Word of Glory", UnitHeal, "WordofGloryFriendRet");
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.WordofGloryFriendRet && SpellManager.HasSpell("Eternal Flame")) && Me.Combat) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && (((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && (UnitHealIsValid && (HealWeightUnitHeal <= THSettings.Instance.WordofGloryFriendRetHP))) && (MyAuraTimeLeft(0x1bdf3, UnitHeal) < 2000.0))) && CanCastCheck("Eternal Flame"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Eternal Flame", UnitHeal, "Eternal Flame - WordofGloryFriendRet");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite WordofGloryHoly()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.WordofGloryHoly && UnitHealIsValid) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && (HealWeightUnitHeal <= THSettings.Instance.WordofGloryHolyHP)) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BeaconOffTarget(UnitHeal);
                CastSpell("Word of Glory", UnitHeal, "WordofGloryHoly");
            }));
        }

        private static Composite WordofGloryMeProt()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.WordofGloryMeProt && !SpellManager.HasSpell("Eternal Flame")) && Me.Combat) && ((PlayerHolyPower >= THSettings.Instance.WordofGloryMeProtHolyPower) || MeHasAura(0x1603e))) && ((Me.HealthPercent <= THSettings.Instance.WordofGloryMeProtHP) && (MyAuraTimeLeft(0x1bdf3, (WoWUnit) Me) < 2000.0))) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Word of Glory", (WoWUnit) Me, "WordofGloryMeProt");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.WordofGloryMeProt && Me.Combat) && ((PlayerHolyPower >= THSettings.Instance.WordofGloryMeProtHolyPower) || MeHasAura(0x1603e))) && ((Me.HealthPercent <= THSettings.Instance.WordofGloryMeProtHP) && (MyAuraTimeLeft(0x1bdf3, (WoWUnit) Me) < 2000.0))) && CanCastCheck("Eternal Flame"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Eternal Flame", (WoWUnit) Me, "Eternal Flame - WordofGloryMeProt");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite WordofGloryMeRet()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.WordofGloryMeRet && !SpellManager.HasSpell("Eternal Flame")) && Me.Combat) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && ((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && (Me.HealthPercent <= THSettings.Instance.WordofGloryMeRetHP))) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Word of Glory", (WoWUnit) Me, "WordofGloryMeRet");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.WordofGloryMeRet && Me.Combat) && ((PlayerHolyPower >= 3.0) || MeHasAura(0x1603e))) && ((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && ((Me.HealthPercent <= THSettings.Instance.WordofGloryMeRetHP) && (MyAuraTimeLeft(0x1bdf3, (WoWUnit) Me) < 2000.0)))) && CanCastCheck("Eternal Flame"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Eternal Flame", (WoWUnit) Me, "Eternal Flame - WordofGloryMeRet");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite WordofGloryMeTopUpRet()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((!SpellManager.HasSpell("Eternal Flame") && !Me.Combat) && ((PlayerHolyPower >= 1.0) || MeHasAura(0x1603e))) && ((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && (Me.HealthPercent <= THSettings.Instance.DoNotHealAbove))) && CanCastCheck("Word of Glory"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Word of Glory", (WoWUnit) Me, "WordofGloryMeTopUpRet");
            })), (Composite) new Decorator(ret => ((!Me.Combat && ((PlayerHolyPower >= 1.0) || MeHasAura(0x1603e))) && ((!Me.get_CurrentMap().IsDungeon && !Me.get_CurrentMap().IsRaid) && ((Me.HealthPercent <= THSettings.Instance.DoNotHealAbove) && (MyAuraTimeLeft(0x1bdf3, (WoWUnit) Me) < 1000.0)))) && CanCastCheck("Eternal Flame"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Eternal Flame", (WoWUnit) Me, "Eternal Flame - WordofGloryMeTopUpRet");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static void WriteCallTimeAura(int auraName)
        {
            SW.Reset();
            SW.Start();
            bool flag = MeHasAura(auraName);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAura({0})={1} take {2} ms", new object[] { auraName, flag, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeAura(string auraName)
        {
            SW.Reset();
            SW.Start();
            bool flag = MeHasAura(auraName);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAura({0})={1} take {2} ms", new object[] { auraName, flag, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeAuraStackCount(int auraName)
        {
            SW.Reset();
            SW.Start();
            double num = MyAuraStackCount(auraName, (WoWUnit) Me);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAuraStackCount({0})={1} take {2} ms", new object[] { auraName, num, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeAuraStackCount(string auraName)
        {
            SW.Reset();
            SW.Start();
            double num = MyAuraStackCount(auraName, (WoWUnit) Me);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAuraStackCount({0})={1} take {2} ms", new object[] { auraName, num, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeAuraTimeLeft(int auraName)
        {
            SW.Reset();
            SW.Start();
            double num = MyAuraTimeLeft(auraName, (WoWUnit) Me);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAuraTimeLeft({0})={1} take {2} ms", new object[] { auraName, num, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeAuraTimeLeft(string auraName)
        {
            SW.Reset();
            SW.Start();
            double num = MyAuraTimeLeft(auraName, (WoWUnit) Me);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeAuraTimeLeft({0})={1} take {2} ms", new object[] { auraName, num, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeFunction(Func<bool> functionName)
        {
            SW.Reset();
            SW.Start();
            bool flag = functionName();
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeFunction({0})={1} take {2} ms", new object[] { functionName, flag, SW.ElapsedMilliseconds });
        }

        private static void WriteCallTimeSpell(string spellName)
        {
            SW.Reset();
            SW.Start();
            bool flag = CanCastCheck(spellName);
            SW.Stop();
            Styx.Common.Logging.Write("WriteCallTimeSpell({0})={1} take {2} ms", new object[] { spellName, flag, SW.ElapsedMilliseconds });
        }

        public override WoWClass Class
        {
            get
            {
                return (WoWClass) WoWClass.Paladin;
            }
        }

        public override Composite CombatBehavior
        {
            get
            {
                return this._combatBehavior;
            }
        }

        public override Composite DeathBehavior
        {
            get
            {
                return this._deathBehavior;
            }
        }

        private static IEnumerable<WoWPartyMember> GroupMembers
        {
            get
            {
                if (Me.get_GroupInfo().IsInRaid)
                {
                    return Me.get_GroupInfo().get_RaidMembers();
                }
                return Me.get_GroupInfo().get_PartyMembers();
            }
        }

        private static LocalPlayer Me
        {
            get
            {
                return StyxWoW.get_Me();
            }
        }

        private static bool MeIsTank
        {
            get
            {
                return ((StyxWoW.get_Me().get_Role() & ((WoWPartyMember.GroupRole) ((int) WoWPartyMember.GroupRole.Tank))) != ((WoWPartyMember.GroupRole) ((int) WoWPartyMember.GroupRole.None)));
            }
        }

        private static double MobsNearby
        {
            [CompilerGenerated]
            get
            {
                return <MobsNearby>k__BackingField;
            }
            [CompilerGenerated]
            set
            {
                <MobsNearby>k__BackingField = value;
            }
        }

        public override string Name
        {
            get
            {
                return "TuanHA Paladin [Special Edition]";
            }
        }

        private static double PlayerHolyPower
        {
            get
            {
                if (((UseSpecialization == 1) && (Me.get_CurrentMap().IsRaid || Me.get_CurrentMap().IsDungeon)) && (Me.IsCasting && (Me.get_CastingSpell().Name == "Holy Radiance")))
                {
                    return (double) (Me.CurrentHolyPower + 1);
                }
                return (double) Me.CurrentHolyPower;
            }
        }

        public override Composite PreCombatBuffBehavior
        {
            get
            {
                return this._preCombatBuffBehavior;
            }
        }

        public override Composite RestBehavior
        {
            get
            {
                return this._restBehavior;
            }
        }

        private static string SelfRezSpell
        {
            [CompilerGenerated]
            get
            {
                return <SelfRezSpell>k__BackingField;
            }
            [CompilerGenerated]
            set
            {
                <SelfRezSpell>k__BackingField = value;
            }
        }

        public override bool WantButton
        {
            get
            {
                return true;
            }
        }

        public delegate float DynamicRangeRetriever(object context);

        public delegate WoWPoint LocationRetriever(object context);

        public delegate bool SimpleBooleanDelegate(object context);

        public delegate WoWUnit UnitSelectionDelegate(object context);
    }
}

